【Nuxt.js】【vue】`create-nuxt-app` で「npm ERR! Failed at the ejs@2.7.4 postinstall script. 」エラーが発生する

困った時対応ログ

新規で Nuxt.js のアプリケーションを作成する際、公式ドキュメント通りの手順でエラーが発生しましたので、その際の対応手順です。

環境

  • Docker for Mac : 2.3.0.3
  • コンテナのbase : node:14.4.0-alpine3.10
  • create-nuxt-app : 2.15.0
  • npm 6.14.5
  • node v14.4.0

事象

$ npx create-nuxt-app firestore-kanzen-rikai-sample
internal/modules/cjs/loader.js:1032
  throw err;
  ^

Error: Cannot find module '/root/.npm/_npx/72/lib/node_modules/create-nuxt-app/node_modules/ejs/postinstall.js'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:1029:15)
    at Function.Module._load (internal/modules/cjs/loader.js:898:27)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
    at internal/main/run_main_module.js:17:47 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! ejs@2.7.4 postinstall: `node ./postinstall.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the ejs@2.7.4 postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2020-06-06T11_01_16_232Z-debug.log
Install for [ 'create-nuxt-app@latest' ] failed with code 1

対応

公式ドキュメントのnpx create-nuxt-app または yarn create nuxt-app では無く、以下のコマンドを実行します。

npm install -g create-nuxt-app
npm init nuxt-app .

実行ログ

$ npm install -g create-nuxt-app
npm WARN deprecated urix@0.1.0: Please see https://github.com/lydell/urix#deprecated
npm WARN deprecated resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated
/usr/local/bin/create-nuxt-app -> /usr/local/lib/node_modules/create-nuxt-app/cli.js

> ejs@2.7.4 postinstall /usr/local/lib/node_modules/create-nuxt-app/node_modules/ejs
> node ./postinstall.js

Thank you for installing EJS: built with the Jake JavaScript build tool (https://jakejs.com/)

+ create-nuxt-app@2.15.0
added 349 packages from 200 contributors in 15.604s

$ npm init nuxt-app .

create-nuxt-app v2.15.0
✨  Generating Nuxt.js project in .
? Project name (app)

# 以降はNuxt.jsのマニュアル通り

参考

Error when building new app · Issue #383 · nuxt/create-nuxt-app
I am getting this error when trying to create a new nuxt app node -v v12.13.1 ` npx create-nuxt-app ui-dev2 internal/modules/cjs/loader.js:800 throw err; ^ Erro

コメント

タイトルとURLをコピーしました