stefr's avatar
Level 9

Laravel Mix suddenly started to give errors

Hi, I have been running Laravel Mix before without any problems. Now (after an npm update) I'm not able to run it again. I figured out that when I remove all the sass (I have two) from the webpack.mix.js it works, so it should have something to do with the sass compiler.

Here is the stacktrace from npm-debug.log:

0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/Cellar/node/7.5.0/bin/node',
1 verbose cli   '/usr/local/bin/npm',
1 verbose cli   'run',
1 verbose cli   'dev' ]
2 info using [email protected]
3 info using [email protected]
4 verbose run-script [ 'predev', 'dev', 'postdev' ]
5 info lifecycle @~predev: @
6 silly lifecycle @~predev: no script for predev, continuing
7 info lifecycle @~dev: @
8 verbose lifecycle @~dev: unsafe-perm in lifecycle true
9 verbose lifecycle @~dev: PATH: /usr/local/lib/node_modules/npm/bin/node-gyp-bin:/Users/myuser/projects/myproject/node_modules/.bin:/usr/local/bin:/usr/local/sbin:/Users/myuser/.dotfiles/bin:/usr/local/opt/php70/bin:node_modules/.bin:vendor/bin:/Users/myuser/.node/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/myuser/.composer/vendor/bin
10 verbose lifecycle @~dev: CWD: /Users/myuser/projects/myproject
11 silly lifecycle @~dev: Args: [ '-c',
11 silly lifecycle   'node node_modules/cross-env/bin/cross-env.js NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js' ]
12 silly lifecycle @~dev: Returned: code: 2  signal: null
13 info lifecycle @~dev: Failed to exec dev script
14 verbose stack Error: @ dev: `node node_modules/cross-env/bin/cross-env.js NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js`
14 verbose stack Exit status 2
14 verbose stack     at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/lifecycle.js:279:16)
14 verbose stack     at emitTwo (events.js:106:13)
14 verbose stack     at EventEmitter.emit (events.js:192:7)
14 verbose stack     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/spawn.js:40:14)
14 verbose stack     at emitTwo (events.js:106:13)
14 verbose stack     at ChildProcess.emit (events.js:192:7)
14 verbose stack     at maybeClose (internal/child_process.js:890:16)
14 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
15 verbose pkgid @
16 verbose cwd /Users/myuser/projects/myproject
17 error Darwin 16.4.0
18 error argv "/usr/local/Cellar/node/7.5.0/bin/node" "/usr/local/bin/npm" "run" "dev"
19 error node v7.5.0
20 error npm  v4.1.2
21 error code ELIFECYCLE
22 error @ dev: `node node_modules/cross-env/bin/cross-env.js NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js`
22 error Exit status 2
23 error Failed at the @ dev script 'node node_modules/cross-env/bin/cross-env.js NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js'.
23 error Make sure you have the latest version of node.js and npm installed.
23 error If you do, this is most likely a problem with the  package,
23 error not with npm itself.
23 error Tell the author that this fails on your system:
23 error     node node_modules/cross-env/bin/cross-env.js NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js
23 error You can get information on how to open an issue for this project with:
23 error     npm bugs
23 error Or if that isn't available, you can get their info via:
23 error     npm owner ls
23 error There is likely additional logging output above.
24 verbose exit [ 1, true ]
0 likes
10 replies
J_shelfwood's avatar

Might be worth trying the LTS version of node to see if that makes a difference

stefr's avatar
Level 9

I've tried Node 6.9.5, no luck here, so I'm back at 7.5.0.

When I downgrade laravel-mix to 0.6.0 the script runs as expected! versions 0.6.1 and up fail.

forehalo's avatar

More information needed:

terminal output

laravel-mix version

stefr's avatar
Level 9

@forehalo it fails on laravel-mix version 0.6.1, 0.6.2 and 0.6.3.

Here is the output with laravel-mix 0.6.3

 ERROR  Failed to compile with 10 errors

These dependencies were not found in node_modules:

* ../fonts/bootstrap/glyphicons-halflings-regular.eot
* ../fonts/bootstrap/glyphicons-halflings-regular.woff2
* ../fonts/bootstrap/glyphicons-halflings-regular.woff
* ../fonts/bootstrap/glyphicons-halflings-regular.ttf
* ../fonts/bootstrap/glyphicons-halflings-regular.svg
* ../fonts/bootstrap/glyphicons-halflings-regular.eot
* ../fonts/bootstrap/glyphicons-halflings-regular.woff2
* ../fonts/bootstrap/glyphicons-halflings-regular.woff
* ../fonts/bootstrap/glyphicons-halflings-regular.ttf
* ../fonts/bootstrap/glyphicons-halflings-regular.svg

Did you forget to run npm install --save for them?                                                                                                                                                                                                                                                                                                Asset       Size  Chunks                    Chunk Names
/admin_assets/js/vendor.f57e0dbf4c39091c77d2.js    1.85 MB    0, 3  [emitted]  [big]  /admin_assets/js/vendor
  /admin_assets/js/main.d9fe4985014bba757801.js     914 kB    1, 3  [emitted]  [big]  /admin_assets/js/main
        /assets/js/main.0521e1ba0354928d5e7e.js    73.4 kB    2, 3  [emitted]         /assets/js/main
    /assets/js/manifest.d41d8cd98f00b204e980.js    5.65 kB       3  [emitted]         /assets/js/manifest
                              mix-manifest.json  306 bytes          [emitted]         

npm ERR! Darwin 16.4.0
npm ERR! argv "/usr/local/Cellar/node/7.5.0/bin/node" "/usr/local/bin/npm" "run" "dev"
npm ERR! node v7.5.0
npm ERR! npm  v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! @ dev: `node node_modules/cross-env/bin/cross-env.js 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 @ dev script 'node node_modules/cross-env/bin/cross-env.js NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the  package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node node_modules/cross-env/bin/cross-env.js NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs 
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls 
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /Users/myuser/projects/myproject/npm-debug.log
stefr's avatar
Level 9

@Slon Go to your package.json file.

change "laravel-mix": "^0.6.0" into (for example) "laravel-mix": "0.6.1" Then run npm install

stefr's avatar
stefr
OP
Best Answer
Level 9

@forehalo laravel-mix just got updated to 0.7.0 I can confirm that this solves the problem!

1 like
b00mtastik's avatar

Hello all,

I'm still very new to Laravel, but I just had this same problem crop up, but then realized that I had made a very simple mistake and wanted to share in case others were having this problem and had done the same thing.

I use PHPStorm as my IDE and when I went to my app.scss file I realized I had added a leading '/' to my import for bootstrap because it was underlined red due to the IDE telling me it couldn't resolve the directory.

But adding that leading '/' as below just before 'node_modules':

@import "/node_modules/bootstrap-sass/assets/stylesheets/bootstrap";

  • is what caused it to error out on me. I got lucky and removed it to prove a theory that webpack will do the resolving and it worked. I came to this post because the OP talked about removing all SCSS files and it was working again (which happened for me as well).

Again this was a simple mistake and what is causing the same error for others could be something else entirely and I could be misunderstanding this, but just to save anyone else the headache incase they ended up doing the same thing as I did.

Please or to participate in this conversation.