Laravel-mix: 'node_modules' is not recognized as an internal or external command

Created on 24 Jan 2017  Â·  27Comments  Â·  Source: JeffreyWay/laravel-mix

After npm install and npm run dev, console show:

@ dev C:\Users\lukas\apps\
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

'node_modules' is not recognized as an internal or external command,
operable program or batch file.

npm ERR! Windows_NT 10.0.15014
npm ERR! argv "C:\NodeJS\node.exe" "C:\NodeJS\node_modules\npm\bin\npm-cli.js" "run" "dev"
npm ERR! node v6.9.4
npm ERR! npm v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! @ dev: 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_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_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:

Most helpful comment

add node ./ in each line, so they look like this:

    "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",
    "watch": "node ./node_modules/cross-env/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",
    "hot": "node ./node_modules/cross-env/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/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"

All 27 comments

I had the same issue. I just had to modify every instance of
"node_modules/cross-env/bin/cross-env.js" with just "cross-env"

nickarellano it's working ;)

Doesn't work for me. 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 right in console works perfectly.

node v7.4.0
npm v4.0.5
npm-debug.txt

I get the same issue. Likely due to the fact we are using Windows. I was really excited to use this new version too...

I have the exact same problem.

As @cjmaxik mentioned above, just put "node" before the 4 scripts defined in the package.json and you are good to go.

@Hendriksie, nope, this doesn't work in package.json, only right in console.

Windows 7 64-bit, NodeJS 6.9.4, npm 4.1.1.

Adding node in front of the script commands worked here. I use GitBash that came with Git.

Any ideas if this change then later on works normally on a non-Windows system?

@cjmaxik, thats weird, I put it in the package.json and when I run npm run dev it works perfectly.

edit: I'm using MING64 to simulate a terminal on Windows

@rask, I tested it on Homestead through SSH, and when having "node" in front of the scripts it still works.

Same issue in Windows 10.

add node ./ in each line, so they look like this:

    "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",
    "watch": "node ./node_modules/cross-env/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",
    "hot": "node ./node_modules/cross-env/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/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"

I tried adding the "node" before but didn't work either. I wasn't even able to npm install correctly I get errors with the webpack package with the fsevents dependency. Is somebody getting the same error on windows?

-- [email protected] +-- [email protected] |-- [email protected] (git://github.com/stephenmathieson/node-globs.git#80bb9161c8c178f8836fff34da3afd1cbc87cedb)
`-- UNMET PEER DEPENDENCY [email protected]

npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.0.0 (node_modules\chokidarnode_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN [email protected] requires a peer of webpack@^2.1.0-beta.19 || ^2.2.0-rc.0 but none was installed.
npm WARN [email protected] requires a peer of webpack@^2.2.0 but none was installed.

We updated the Laravel repo to add "node" to the beginning of each NPM script.

@GDanielRG You have something unrelated to this issue. You can file a new one if it's still not working after checking your Node/NPM versions and redoing npm install.

@JeffreyWay Yes indeed I was having another issue which I just resolved and adding the node at the beginning of script worked! thanks!

I have the same issue, I just followed the Laracast tutorial Laravel Mix and the Front-end

npm run dev

@ dev C:\Users\Said\Desktop\Project\laravel\blog
> 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

module.js:472
    throw err;
    ^

Error: Cannot find module 'C:\Users\Said\Desktop\Project\laravel\blog\node_modules\cross-env\dist\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:425:7)
    at startup (bootstrap_node.js:146:9)
    at bootstrap_node.js:540:3

npm ERR! Windows_NT 10.0.14393
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\Said\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "run" "dev"
npm ERR! node v7.7.1
npm ERR! npm  v4.3.0
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ 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`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @ dev script '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'.
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/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
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\Said\AppData\Roaming\npm-cache\_logs\2017-03-08T01_49_42_466Z-debug.log

Also have the same issue as above.
Just updated NPM/Node today with current LTS branch

Windows 10 1607, OS Build 14393.726

npm -v
3.10.10

node -v
v6.10.0

Resolved by updating package.json, and reinstalling node-sass manully.

{
  "private": true,
  "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"
  },
  "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.2.2"
  }
}

followed by

npm install node-sass

working correctly now.

@wing5wong You are a life saver. I was going nuts! +1

Using Homestead and receiving still error as follows even if following wing5wong's method:

@ dev /home/vagrant/www/test
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

undefined:1
�FU�]���k�-8T��8��-rm�_J��p���8��-rm�_J��p���8��-rm�_J��p��
^

SyntaxError: Unexpected token � in JSON at position 0
....

npm ERR! Linux 4.4.0-51-generic
npm ERR! argv "/usr/local/bin/node" "/usr/bin/npm" "run" "dev"
npm ERR! node v7.8.0
npm ERR! npm v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! @ 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
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @ dev script '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'.
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/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

@Umelev that looks like you have a syntax error in your configs. Validate your JSON and see if it continues.

You can solve this problem 100%
https://github.com/AttaUrRehman24/laravel-mix

@AttaUrRehman24 Why don't you use Gist instead of a git repo which does absolutely nothing?

@rask Thank you for your reply.

The thing was that something had completely messed up my .babelrc file which caused npm fail... No idea what was it but working now.

For anyone who is struggling and just wants to skip the Laravel mix npm commands & environments until a fix comes out for Windows - you could just talk to Webpack directly:

webpack --config=node_modules/laravel-mix/setup/webpack.config.js

Install _cross-dev_ globally with npm install -g cross-dev and modify _package.json_ by placing node in front of each executed Javascript.

For example, my _package.json_ now looks like this:

    "development": "cross-env NODE_ENV=development node node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
    "watch": "cross-env NODE_ENV=development node node_modules/webpack/bin/webpack.js --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
    "watch-poll": "npm run watch -- --watch-poll",
    "hot": "cross-env NODE_ENV=development node node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js",
    "prod": "npm run production",
    "production": "cross-env NODE_ENV=production node node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"

npm install -save-dev babel-preset-es2015
"scripts": {
"compile": "babel src --presets react,es2015 --out-dir static",
"watch": "babel src --presets react,es2015 --out-dir static --watch",
"test": "echo \"Error: no test specified\" && exit 1"
}
Works for me

If anyone still is running into an issue with getting this to run in the WIndows OS command line, try this:

"watch": "SET NODE_ENV=development & node node_modules/webpack/bin/webpack.js --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"

Add "SET" before "NODE_ENV" and then " & node" before the file name. That is the only thing that worked for me.

Hope this helps.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Micaso picture Micaso  Â·  3Comments

amin101 picture amin101  Â·  3Comments

mstralka picture mstralka  Â·  3Comments

sdebacker picture sdebacker  Â·  3Comments

rderimay picture rderimay  Â·  3Comments