laravel-mix: Sudden "npm run dev" error after update to 0.8.3 (0.8.1 still works)
- Laravel Mix Version: 0.8.3
- Node Version (
node -v): 7.6.0 - NPM Version (
npm -v): 4.2.0 - OS: MacOS Sierra
Description:
After updating laravel-mix to 0.8.3 I suddenly get an error on “npm run dev”.
Steps To Reproduce:
- I ran “npm update”
- Only laravel-mix updated itself from 0.8.1 to 0.8.3
- Type “npm run dev”
- Error!
- Set laravel-mix version to 0.8.2 + npm update + npm run dev
- Still error!
- Set laravel-mix version to 0.8.1 + npm update + npm run dev
- Phew it works again.
CMD output:
@ dev /Users/thom/Sites/vacatures 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
module.js:472 throw err; ^
Error: Cannot find module ‘/Users/thom/Sites/vacatures/node_modules/cross-env/bin/cross-env.js’ at Function.Module._resolveFilename (module.js:470:15) at Function.Module._load (module.js:418:25) at Module.runMain (module.js:605:10) at run (bootstrap_node.js:422:7) at startup (bootstrap_node.js:143:9) at bootstrap_node.js:537:3
npm ERR! Darwin 16.4.0
npm ERR! argv “/usr/local/bin/node” “/usr/local/bin/npm” “run” “dev”
npm ERR! node v7.6.0
npm ERR! npm v4.2.0
npm ERR! code ELIFECYCLE
npm ERR! errno 1
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 1
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/thom/.npm/_logs/2017-02-22T22_06_58_870Z-debug.log 2017-02-22T22_06_58_870Z-debug.log.txt
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 9
- Comments: 38 (6 by maintainers)
Commits related to this issue
- Refactor npm scripts Per #4147, this adds a new `npm run watch-poll` command, and dries up some of those long repetitive commands. — committed to laravel/laravel by JeffreyWay 7 years ago
- update laravel-mix fix https://github.com/JeffreyWay/laravel-mix/issues/450 — committed to tradzero/laravel-echo-redis-socketio by tradzero 7 years ago
For me the quick solution was this
Okay, updating the package.json to the new version in Laravel’s master branch does indeed fix the problem I have.
Running npm run dev works now, but it does produce a deprecation warning, just so you know: “DeprecationWarning: loaderUtils.parseQuery() received a non-string value which can be problematic, see https://github.com/webpack/loader-utils/issues/56 parseQuery() will be replaced with getOptions() in the next major version of loader-utils.”
Not sure if I should close this issue, because probably many others who type “npm update” will get this problem?
@JeffreyWay it looks to me like the fix is still potentially suffering from a reference issue with
cross-env; this is my experience on a brand new install today:Brand new site, ran it multiple times, and ran into this issue:
Tried to run it with
npm install && npm run dev; same error, but better stack trace:I took a look at the
node_modules/cross-env/directory, and there’s nonode_modules/cross-env/bin/cross-env.js–instead, it’s innode_modules/cross-env/dist/bin/cross-env.js.Here’s my package.json:
I still get an error:
I have just installed laravel (fresh install) and am getting the same exact problem.
This is my fault. I removed the
cross-envbecause we stopped referencing it in the default package.json file… only to forget that most people will still be using the old package.json. I fixed this today with 0.8.4. Please donpm update laravel-mix.Also, make sure that your package.json file looks like this: https://github.com/laravel/laravel/blob/c76716f228d809d24d1886c3e279d08fb8377ebc/package.json
That will fix the stupid
%npm_package_config_webpack%vs$npm_package_config_webpackissue that makes no sense.@jeshtan yes, I can confirm that. See #452
@terrylow as comment you have to use %npm_package_config_webpack% instead of “$npm_package_config_webpack” for Windows
However I noticed a new problem, the
mix.js('resources/assets/js/app.js', 'public/js')will put compiled javascript file uner<root>/public/public/jsdirectory… Anyone can help confirm?Np, for those who don’t know exactly where to look, make sure your package.json is updated like in this commit
Running npm install solved my issue.
Per Jeff’s comment:
cross-env was removed from mix, not removed completely if you’re still using Laravel. Some OSs require cross-env. You either have to remove any references to ‘cross-env’ from your scripts in package.json, or you have to make sure it is installed.
@krish-ryan Did you even read the release notes for
v1.0? You are supposed to removecross-envfrom the scripts.@Silverspur No they don’t. I bet you have an old version installed. Fresh Laravel installs pull in cross-env directly.
I’m wondering why this issue is closed. @ThomHurks the commit you referenced above has been reverted two days later, and as a result, fresh Laravel installs now “natively” have the issue you mention.
Same here. Using the previous version of package.json seems to fix it.