Laravel-mix: npm run dev failing with error, code ELIFECYCLE

Created on 18 Sep 2017  ·  16Comments  ·  Source: JeffreyWay/laravel-mix

Install a fresh Laravel 5.5, configured the db and composer update.
Then i run the command yarn, it goes well.
While i run the command npm run dev it shows an error and build failed.

  • Laravel Mix Version: #.#.# (npm list --depth=0)
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
└── [email protected]

  • Node Version (node -v): v8.5.0
  • NPM Version (npm -v): 5.3.0
  • OS: Ubuntu 16.04

Description:

npm run dev failed with error. Here is the output the error log.

> @ dev /var/www/html/laravel/test-laravel
> npm run development


> @ development /var/www/html/laravel/test-laravel
> cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js

 95% emitting                                                                         

 ERROR  Failed to compile with 1 errors                                                                                                                                            15:42:00

 error  in ./resources/assets/js/components/Example.vue

Module build failed: Error: Cannot find module './lib/beautify'
    at Function.Module._resolveFilename (module.js:527:15)
    at Function.Module._load (module.js:476:23)
    at Module.require (module.js:568:17)
    at require (internal/module.js:11:18)
    at /var/www/html/laravel/test-laravel/node_modules/js-beautify/js/index.js:74:27
    at Object.<anonymous> (/var/www/html/laravel/test-laravel/node_modules/js-beautify/js/index.js:80:7)
    at Module._compile (module.js:624:30)
    at Object.Module._extensions..js (module.js:635:10)
    at Module.load (module.js:545:32)
    at tryModuleLoad (module.js:508:12)
    at Function.Module._load (module.js:500:3)
    at Module.require (module.js:568:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/var/www/html/laravel/test-laravel/node_modules/vue-loader/lib/template-compiler/index.js:4:16)
    at Module._compile (module.js:624:30)
    at Object.Module._extensions..js (module.js:635:10)
    at Module.load (module.js:545:32)
    at tryModuleLoad (module.js:508:12)
    at Function.Module._load (module.js:500:3)
    at Module.require (module.js:568:17)
    at require (internal/module.js:11:18)
    at loadLoader (/var/www/html/laravel/test-laravel/node_modules/loader-runner/lib/loadLoader.js:13:17)
    at iteratePitchingLoaders (/var/www/html/laravel/test-laravel/node_modules/loader-runner/lib/LoaderRunner.js:169:2)
    at runLoaders (/var/www/html/laravel/test-laravel/node_modules/loader-runner/lib/LoaderRunner.js:362:2)
    at NormalModule.doBuild (/var/www/html/laravel/test-laravel/node_modules/webpack/lib/NormalModule.js:182:3)
    at NormalModule.build (/var/www/html/laravel/test-laravel/node_modules/webpack/lib/NormalModule.js:275:15)
    at Compilation.buildModule (/var/www/html/laravel/test-laravel/node_modules/webpack/lib/Compilation.js:149:10)
    at factoryCallback (/var/www/html/laravel/test-laravel/node_modules/webpack/lib/Compilation.js:337:12)
    at factory (/var/www/html/laravel/test-laravel/node_modules/webpack/lib/NormalModuleFactory.js:241:5)
    at applyPluginsAsyncWaterfall (/var/www/html/laravel/test-laravel/node_modules/webpack/lib/NormalModuleFactory.js:94:13)

 @ ./resources/assets/js/components/Example.vue 6:2-212
 @ ./resources/assets/js/app.js
 @ multi ./resources/assets/js/app.js ./resources/assets/sass/app.scss

                                                                                                    Asset     Size  Chunks                    Chunk Names
  fonts/vendor/bootstrap-sass/bootstrap/glyphicons-halflings-regular.eot?f4769f9bdb7466be65088239c12046d1  20.1 kB          [emitted]         
fonts/vendor/bootstrap-sass/bootstrap/glyphicons-halflings-regular.woff2?448c34a56d699c29117adc64c43affeb    18 kB          [emitted]         
 fonts/vendor/bootstrap-sass/bootstrap/glyphicons-halflings-regular.woff?fa2772327f55d8198301fdb8bcfc8158  23.4 kB          [emitted]         
  fonts/vendor/bootstrap-sass/bootstrap/glyphicons-halflings-regular.ttf?e18bbf611f2a2e43afc071aa2f4e1512  45.4 kB          [emitted]         
  fonts/vendor/bootstrap-sass/bootstrap/glyphicons-halflings-regular.svg?89889688147bd7575d6327160d64e760   109 kB          [emitted]         
                                                                                               /js/app.js  1.21 MB       0  [emitted]  [big]  /js/app
                                                                                             /css/app.css   147 kB       0  [emitted]         /js/app
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!     /home/nasirkhan/.npm/_logs/2017-09-18T09_42_00_813Z-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!     /home/nasirkhan/.npm/_logs/2017-09-18T09_42_00_939Z-debug.log

Error log

0 info it worked if it ends with ok
1 verbose cli [ '/usr/bin/node', '/usr/bin/npm', 'run', 'dev' ]
2 info using [email protected]
3 info using [email protected]
4 verbose run-script [ 'predev', 'dev', 'postdev' ]
5 info lifecycle @~predev: @
6 info lifecycle @~dev: @
7 verbose lifecycle @~dev: unsafe-perm in lifecycle true
8 verbose lifecycle @~dev: PATH: /usr/lib/node_modules/npm/bin/node-gyp-bin:/var/www/html/laravel/test-laravel/node_modules/.bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/nasirkhan/Android/Sdk/platform-tools:/home/nasirkhan/Android/Sdk/tools
9 verbose lifecycle @~dev: CWD: /var/www/html/laravel/test-laravel
10 silly lifecycle @~dev: Args: [ '-c', 'npm run development' ]
11 silly lifecycle @~dev: Returned: code: 2  signal: null
12 info lifecycle @~dev: Failed to exec dev script
13 verbose stack Error: @ dev: `npm run development`
13 verbose stack Exit status 2
13 verbose stack     at EventEmitter.<anonymous> (/usr/lib/node_modules/npm/lib/utils/lifecycle.js:289:16)
13 verbose stack     at emitTwo (events.js:125:13)
13 verbose stack     at EventEmitter.emit (events.js:213:7)
13 verbose stack     at ChildProcess.<anonymous> (/usr/lib/node_modules/npm/lib/utils/spawn.js:40:14)
13 verbose stack     at emitTwo (events.js:125:13)
13 verbose stack     at ChildProcess.emit (events.js:213:7)
13 verbose stack     at maybeClose (internal/child_process.js:927:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5)
14 verbose pkgid @
15 verbose cwd /var/www/html/laravel/test-laravel
16 verbose Linux 4.4.0-93-generic
17 verbose argv "/usr/bin/node" "/usr/bin/npm" "run" "dev"
18 verbose node v8.5.0
19 verbose npm  v5.3.0
20 error code ELIFECYCLE
21 error errno 2
22 error @ dev: `npm run development`
22 error Exit status 2
23 error Failed at the @ dev script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 2, true ]

Steps To Reproduce:

composer create-project --prefer-dist laravel/laravel blog

yarn

npm run dev

Most helpful comment

npm cache clean --force

rm -rf node_modules package-lock.json

npm install

All 16 comments

Use yarn dev since you have already used yarn. Use npm run dev when you use npm install.

You are probably going to mess up some packages by mixing two different package managers.

@ruchern tried that too. got the same error

 yarn dev
yarn dev v1.0.1
$ npm run development

> @ development /var/www/html/laravel/test-laravel
> cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js

 95% emitting                                                                         

 ERROR  Failed to compile with 1 errors                                                                                                  17:05:36

 error  in ./resources/assets/js/components/Example.vue

Module build failed: Error: Cannot find module './lib/beautify'
    at Function.Module._resolveFilename (module.js:527:15)
    at Function.Module._load (module.js:476:23)
    at Module.require (module.js:568:17)
    at require (internal/module.js:11:18)
    at /var/www/html/laravel/test-laravel/node_modules/js-beautify/js/index.js:74:27
    at Object.<anonymous> (/var/www/html/laravel/test-laravel/node_modules/js-beautify/js/index.js:80:7)
    at Module._compile (module.js:624:30)
    at Object.Module._extensions..js (module.js:635:10)
    at Module.load (module.js:545:32)
    at tryModuleLoad (module.js:508:12)
    at Function.Module._load (module.js:500:3)
    at Module.require (module.js:568:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/var/www/html/laravel/test-laravel/node_modules/vue-loader/lib/template-compiler/index.js:4:16)
    at Module._compile (module.js:624:30)
    at Object.Module._extensions..js (module.js:635:10)
    at Module.load (module.js:545:32)
    at tryModuleLoad (module.js:508:12)
    at Function.Module._load (module.js:500:3)
    at Module.require (module.js:568:17)
    at require (internal/module.js:11:18)
    at loadLoader (/var/www/html/laravel/test-laravel/node_modules/loader-runner/lib/loadLoader.js:13:17)
    at iteratePitchingLoaders (/var/www/html/laravel/test-laravel/node_modules/loader-runner/lib/LoaderRunner.js:169:2)
    at runLoaders (/var/www/html/laravel/test-laravel/node_modules/loader-runner/lib/LoaderRunner.js:362:2)
    at NormalModule.doBuild (/var/www/html/laravel/test-laravel/node_modules/webpack/lib/NormalModule.js:182:3)
    at NormalModule.build (/var/www/html/laravel/test-laravel/node_modules/webpack/lib/NormalModule.js:275:15)
    at Compilation.buildModule (/var/www/html/laravel/test-laravel/node_modules/webpack/lib/Compilation.js:149:10)
    at factoryCallback (/var/www/html/laravel/test-laravel/node_modules/webpack/lib/Compilation.js:337:12)
    at factory (/var/www/html/laravel/test-laravel/node_modules/webpack/lib/NormalModuleFactory.js:241:5)
    at applyPluginsAsyncWaterfall (/var/www/html/laravel/test-laravel/node_modules/webpack/lib/NormalModuleFactory.js:94:13)

 @ ./resources/assets/js/components/Example.vue 6:2-212
 @ ./resources/assets/js/app.js
 @ multi ./resources/assets/js/app.js ./resources/assets/sass/app.scss

                                                                                                    Asset     Size  Chunks                    Chunk Names
  fonts/vendor/bootstrap-sass/bootstrap/glyphicons-halflings-regular.eot?f4769f9bdb7466be65088239c12046d1  20.1 kB          [emitted]         
fonts/vendor/bootstrap-sass/bootstrap/glyphicons-halflings-regular.woff2?448c34a56d699c29117adc64c43affeb    18 kB          [emitted]         
 fonts/vendor/bootstrap-sass/bootstrap/glyphicons-halflings-regular.woff?fa2772327f55d8198301fdb8bcfc8158  23.4 kB          [emitted]         
  fonts/vendor/bootstrap-sass/bootstrap/glyphicons-halflings-regular.ttf?e18bbf611f2a2e43afc071aa2f4e1512  45.4 kB          [emitted]         
  fonts/vendor/bootstrap-sass/bootstrap/glyphicons-halflings-regular.svg?89889688147bd7575d6327160d64e760   109 kB          [emitted]         
                                                                                               /js/app.js  1.21 MB       0  [emitted]  [big]  /js/app
                                                                                             /css/app.css   147 kB       0  [emitted]         /js/app
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!     /home/nasirkhan/.npm/_logs/2017-09-18T11_05_36_348Z-debug.log
error Command failed with exit code 2.

Probably related #1195.

Try downgrading to Laravel Mix 1.4.2 and see it problem persist.

npm install [email protected]

I have the same problem

Probably related
https://github.com/beautify-web/js-beautify/issues/1247

devDependencies
please try add
"js-beautify": "1.6.14"

DONE Compiled successfully

Time to remove "js-beautify": "1.6.14" from your "dependencies":{} and "resolve":{}
[email protected] has been published, please update.

https://twitter.com/vuejs/status/909785891941617664

I found your problem. Update that package. It seemed likely they have patched it.

the issue has resolved. it was related to https://github.com/beautify-web/js-beautify/issues/1247, the maintainer pushed the release and went to sleep and the disaster happened in between. (https://twitter.com/bitwiseman/status/909841462312935426)

@nasirkhan, the original issue doesn't affect this repo anymore anyway, because vue-loader switched to prettier.

The way the package got broken is quite curious too 🅱eautify-web/js-🅱eautify/pull/1241

no upgrade laravel-mix this is the problem

same error ,

Probably close this issue.

same error

same error

npm cache clean --force

rm -rf node_modules package-lock.json

npm install

1

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mstralka picture mstralka  ·  3Comments

jpriceonline picture jpriceonline  ·  3Comments

nezaboravi picture nezaboravi  ·  3Comments

pixieaka picture pixieaka  ·  3Comments

hasnatbabur picture hasnatbabur  ·  3Comments