0
0

More than 1 year has passed since last update.

npm install && npm run devのエラー発生

Posted at

npm install && npm run devのエラーが発生

//下記エラー
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ development: `cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @ development 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/2021-09-26T13_18_53_799Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ dev: `npm run development`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @ dev 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/2021-09-26T13_18_53_836Z-debug.log

原因

package.json内のバージョンが原因でnode.jsのライブラリをインストールしようとするとエラーが発生した模様

解決策

package.json
"devDependencies": {
"axios": "^0.19",
"bootstrap": "^4.6.0",
"cross-env": "^7.0",
"jquery": "^3.6",
"laravel-mix": "^5.0.1",
"lodash": "^4.17.19",
"popper.js": "^1.16.1",
"resolve-url-loader": "^3.1.2",
"sass": "^1.32.11",
"sass-loader": "^11.0.1", // "10.1.1"に変更。
"vue": "^2.6.12",
"vue-template-compiler": "^2.6.12"
}

laravel-mixのバージョンが5系だったので、6系だと下記の書き方が少々違っていた模様。

[webpack.mix.js]
mix.js('resources/js/app.js', 'public/js')
.vue() //コメントアウトする。もしくは消す。
.sass('resources/sass/app.scss', 'public/css');

下記コマンドで再度インストールする。

//nodeモジュールを削除
rm -rf node_modules

//package-lock.jsonファイルを削除
rm package-lock.json

//npmのキャッシュをクリア
npm cache clear --force

//再インストール
npm install

//再度、動作確認
npm run dev

以上

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0