framework: [5.4] "Npm run" commands don't work on windows.
- Laravel Version: 5.4.1
- PHP Version: 7.0.4
- node v6.9.4
- npm v3.10.5
Description:
npm commands are completely broken on windows (windows 7 in this case), whenever I run npm run dev I get the following error:
'node_modules' is not recognized as an internal or external command,
operable program or batch file.
I tried
"scripts": {
"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"
},
It ran but without success:
> @ dev c:\wamp\www\web
> 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.co
nfig.js
path.js:7
throw new TypeError('Path must be a string. Received ' + inspect(path));
^
TypeError: Path must be a string. Received undefined
at assertPath (path.js:7:11)
at Object.parse (path.js:950:5)
at new File (c:\wamp\www\web\node_modules\laravel-mix\src\File.js:14:30)
at Object.module.exports.preprocess (c:\wamp\www\web\node_modules\laravel-mix\src\index.js:108:14)
at Object.module.exports.sass (c:\wamp\www\web\node_modules\laravel-mix\src\index.js:84:27)
at Object.<anonymous> (c:\wamp\www\web\webpack.mix.js:17:5)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Mix.initialize (c:\wamp\www\flores\node_modules\laravel-mix\src\Mix.js:38:9)
at Object.<anonymous> (c:\wamp\www\flores\node_modules\laravel-mix\setup\webpack.config.js:18:5)
at Module._compile (module.js:570:32)
Steps To Reproduce:
Run npm run dev command on windows.
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 2
- Comments: 24 (10 by maintainers)
@taylorotwell go in package.json and instead of “scripts”: { “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”, “watch”: “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_modules/cross-env/bin/cross-env.js NODE_ENV=development webpack-dev-server --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js”, “production”: “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” },
put this: “scripts”: { “dev”: “cross-env NODE_ENV=development webpack --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js”, “watch”: “cross-env NODE_ENV=development webpack --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js”, “hot”: “cross-env NODE_ENV=development webpack-dev-server --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js”, “production”: “cross-env NODE_ENV=production webpack --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js” },
I hope I help 😃
Looks like I may have to get my PC out of the closet 😃 … can anyone confirm a working resolution that works on both mac and Windows?
These are the scripts as they are meant to be:
@Frondor - At this point, your question is specifically related to Laravel Mix. It doesn’t have anything to do with the framework code. I’m going to port this question over there.
https://github.com/JeffreyWay/laravel-mix/issues/185
Win 8, node 7.4.0, npm 4.0.5 Laravel 5.4.3 everything works perfectly. Thanks for all the work put into this.
Just installed Laravel 5.4.3 on my windows machine and then ran
npm install
and then tried
npm run dev, npm run watch and it works perfectly fine for me.
You can solve this problem 100% https://github.com/AttaUrRehman24/laravel-mix
Same problem win 10 64bits wampserver php7
Solution: Update windows npm with installer https://nodejs.org/en/download/