laravel-mix: Cannot find module '/home/vagrant/Code/blog/node_modules/cross-env/bin/cross-env.js
- Laravel Mix Version: 0.6.0
- Node Version (
node -v): 5.10.1 - NPM Version (
npm -v): 3.8.3 - OS: macOS Sierra 10.12.3
Description:
On my fresh Laravel 5.4.14, running npm run dev gets into this 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
module.js:341
throw err;
^
Error: Cannot find module '/home/vagrant/Code/blog/node_modules/cross-env/bin/cross-env.js'
at Function.Module._resolveFilename (module.js:339:15)
at Function.Module._load (module.js:290:25)
at Function.Module.runMain (module.js:447:10)
at startup (node.js:146:18)
at node.js:404:3
npm ERR! Linux 3.19.0-25-generic
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "run" "dev"
npm ERR! node v5.10.1
npm ERR! npm v3.8.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! /home/vagrant/Code/repoducing-laravel-mix-issue-519/npm-debug.log
So I read through these similar issues, https://github.com/JeffreyWay/laravel-mix/issues/519, https://github.com/JeffreyWay/laravel-mix/issues/523, https://github.com/laravel/framework/issues/17528, but got no luck.
After updating my Laravel from 5.4.14 to 5.4.15 by running composer install and npm install afterwards, still got the same error.
Also reproduced on a fresh Laravel 5.4.15 installation by running composer global require "laravel/installer", the error still persist in npm run dev.
Steps To Reproduce:
- Install a new Laravel app: $
composer create-project --prefer-dist laravel/laravel blog - Install NPM modules: $
npm install - Run: $
npm run dev
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 1
- Comments: 16
The cross-env package change the bin directory path from cross-env/bin to cross-env/dist/bin
just update your package.json file:
sudo npm install sudo npm run dev
Here’s my package.json:
The only thing changed here is that I’ve changed:
"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",to:
"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",Still having the errors thou up to now.
@doncadavona Update Node. You have an outdated version.
@asimshazad @shemi already posted a solution for your issue.