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

Most upvoted comments

For me the quick solution was this

  "scripts": {
    "dev": "node node_modules/cross-env/dist/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",
    "watch": "node node_modules/cross-env/dist/bin/cross-env.js NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
    "watch-poll": "node node_modules/cross-env/dist/bin/cross-env.js NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --watch-poll --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
    "hot": "node node_modules/cross-env/dist/bin/cross-env.js NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js",
    "production": "node node_modules/cross-env/dist/bin/cross-env.js NODE_ENV=production node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"
  }

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:

laravel new webpack-global-test && cd webpack-global-test && yarn && yarn run dev

Brand new site, ran it multiple times, and ran into this issue:

Error: Cannot find module '/Users/mattstauffer/Sites/webpack-global-test/node_modules/cross-env/bin/cross-env.js'
    at Function.Module._resolveFilename (module.js:455:15)
    at Function.Module._load (module.js:403:25)
    at Module.runMain (module.js:590:10)
    at run (bootstrap_node.js:394:7)
    at startup (bootstrap_node.js:149:9)
    at bootstrap_node.js:509:3
error Command failed with exit code 1.

Tried to run it with npm install && npm run dev; same error, but better stack trace:

npm ERR! Darwin 16.4.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "dev"
npm ERR! node v6.4.0
npm ERR! npm  v3.10.3
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 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/mattstauffer/Sites/webpack-global-test/npm-debug.log

I took a look at the node_modules/cross-env/ directory, and there’s no node_modules/cross-env/bin/cross-env.js–instead, it’s in node_modules/cross-env/dist/bin/cross-env.js.

Here’s my package.json:

  "devDependencies": {
    "axios": "^0.15.3",
    "bootstrap-sass": "^3.3.7",
    "jquery": "^3.1.1",
    "laravel-mix": "^0.8.1",
    "lodash": "^4.17.4",
    "vue": "^2.1.10"
  }
  • Laravel Mix Version: 0.8.8
  • Node Version (node -v): 6.4.0
  • NPM Version (npm -v): 3.10.3
  • OS: MacOS Sierra

I still get an error:

franc@ALIENWARE ~/PhpstormProjects/MaisonDuPain                                                           
λ npm run dev                                                                                             
                                                                                                          
> @ dev C:\Users\franc\PhpstormProjects\MaisonDuPain                                                      
> node node_modules/webpack/bin/webpack.js --progress --hide-modules --config=$npm_package_config_webpack 
                                                                                                          
module.js:472                                                                                             
    throw err;                                                                                            
    ^                                                                                                     
                                                                                                          
Error: Cannot find module 'C:\Users\franc\PhpstormProjects\MaisonDuPain\$npm_package_config_webpack'      
    at Function.Module._resolveFilename (module.js:470:15)                                                
    at Function.Module._load (module.js:418:25)                                                           
    at Module.require (module.js:498:17)                                                                  
    at require (internal/module.js:20:19)                                                                 
    at requireConfig (C:\Users\franc\PhpstormProjects\MaisonDuPain\node_modules\webpack\bin\convert-argv.j
s:96:18)                                                                                                  
    at C:\Users\franc\PhpstormProjects\MaisonDuPain\node_modules\webpack\bin\convert-argv.js:109:17       
    at Array.forEach (native)                                                                             
    at module.exports (C:\Users\franc\PhpstormProjects\MaisonDuPain\node_modules\webpack\bin\convert-argv.
js:107:15)                                                                                                
    at Object.<anonymous> (C:\Users\franc\PhpstormProjects\MaisonDuPain\node_modules\webpack\bin\webpack.j
s:153:40)                                                                                                 
    at Module._compile (module.js:571:32)                                                                 
                                                                                                          
npm ERR! Windows_NT 10.0.14393                                                                            
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\franc\\AppData\\Roaming\\npm\\node_modules
\\npm\\bin\\npm-cli.js" "run" "dev"                                                                       
npm ERR! node v7.4.0                                                                                      
npm ERR! npm  v3.10.8                                                                                     
npm ERR! code ELIFECYCLE                                                                                  
npm ERR! @ dev: `node node_modules/webpack/bin/webpack.js --progress --hide-modules --config=$npm_package_
config_webpack`                                                                                           
npm ERR! Exit status 1                                                                                    
npm ERR!                                                                                                  
npm ERR! Failed at the @ dev script 'node node_modules/webpack/bin/webpack.js --progress --hide-modules --
config=$npm_package_config_webpack'.                                                                      
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/webpack/bin/webpack.js --progress --hide-modules --config=$npm_package_conf
ig_webpack                                                                                                
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!     C:\Users\franc\PhpstormProjects\MaisonDuPain\npm-debug.log                                   
franc@ALIENWARE ~/PhpstormProjects/MaisonDuPain                                                           
λ                                                                                                         

I have just installed laravel (fresh install) and am getting the same exact problem.

node node_modules/webpack/bin/webpack.js --progress --hide-modules --config=$npm_package_config_webpack

module.js:472
    throw err;
    ^
Error: Cannot find module 'C:\wamp64\www\outfitdesigner\$npm_package_config_webpack'

This is my fault. I removed the cross-env because 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 do npm 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_webpack issue 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/js directory… 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 has been removed as a dependency of Mix. It doesn’t make sense for us to maintain it. Frameworks like Laravel will already pull in cross-env, but for your personal projects, either open your package.json file and remove the cross-env path from all of your npm scripts, or do npm install cross-env.

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 remove cross-env from 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.