npm Community Forum (Archive)

The npm community forum has been discontinued.

To discuss usage of npm, visit the GitHub Support Community.

error in doing npm run dev

npm ERR! code ELIFECYCLE
npm ERR! errno 2
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 2
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! C:\Users\LONOVO\AppData\Roaming\npm-cache_logs\2019-02-18T16_27_37_768Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! @ dev: npm run development
npm ERR! Exit status 2
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! C:\Users\LONOVO\AppData\Roaming\npm-cache_logs\2019-02-18T16_27_37_973Z-debug.log


Looks like the command which failed was webpack (or cross-env).

You can run the command quoted in the log directly yourself which is often handy to reduce the number of extra messages and try one thing at a time. e.g. to run just the webpack part

NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js


watch this video


When you type npm run <name> it runs that named script from the scripts in package.json. The difference between the scripts before and after the copy/paste in the video was putting the cross-env on the front (which set NODE_ENV to development), and changing the value for --config.

I don’t know what the right --config is for your project. This might be a question to ask in a laravel forum, as I don’t think the problem is with npm itself.