node -v
): 7.6.0 npm -v
): 4.2.0After updating laravel-mix to 0.8.3 I suddenly get an error on "npm run dev".
@ 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
Upon further investigation I did notice that in a new Laravel project the package.json is different now. If a new package.json format is required for the newer Laravel-mix version, then perhaps a bigger version nr increase was warranted so it wouldn't have automatically updated and it's clear a manual update is necessary. Is this the case?
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?
I'm running npm run production as part of deploy. They started failing and this was the solution thanks @ThomHurks
Np, for those who don't know exactly where to look, make sure your package.json is updated like in this commit
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
λ
@Francismori7 That looks like the error i got when i only copied the npm scripts and not this object
https://github.com/laravel/laravel/blob/master/package.json#L11
Exactly what I did, then added the proper line in and it's still the error
I keep getting. Tried removing modules and reinstalling but to no avail
On Wed, Feb 22, 2017, 20:02 Scott Grayson notifications@github.com wrote:
@Francismori7 https://github.com/Francismori7 That looks like the error
i got when i only copied the npm scripts and not this line
https://github.com/laravel/laravel/blob/master/package.json#L11—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/JeffreyWay/laravel-mix/issues/450#issuecomment-281856626,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAfxx4SDk5d6X2xu35v-gesEIHCmAlJeks5rfNqugaJpZM4MJQz8
.
Same issue as @Francismori7 , already update package.json
OS: WIndows 10,
npm : 4.3.0
node: 7.5.0
@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?
@jeshtan yes, I can confirm that. See #452
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.
@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"
}
Same here. Using the previous version of package.json seems to fix it.
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"
}
@turzaizsolt Thank you! I don't use npm
and was feeling lost. Your suggestion worked for me. :smile:
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.
@Silverspur No they don't. I bet you have an old version installed. Fresh Laravel installs pull in cross-env directly.
My bad, I did not look carrefully enough at my error message, which was different (after a fresh install) from the one discussed here.
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'
I have the same issue .. i tired many things with no luck
same issue with me.... so tired ...try to find a solution but still not found...
Hi solved running this
npm install --save-dev cross-env
@marcoax Which OS are you running on?
For macOS and Linux, this should not be needed and in fact, it is going to be removed in v1.0
I'm on window and i've a fresh install of laravel 5.5
Can someone please help me with this issue,
I am getting this error while npm run watch
Osx yosamite,
node v8.1.2
npm 5.0.3
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
module.js:487
throw err;
^
Error: Cannot find module '/_local/krish/laravel/demo/node_modules/cross-env/bin/cross-env.js'
at Function.Module._resolveFilename (module.js:485:15)
at Function.Module._load (module.js:437:25)
at Function.Module.runMain (module.js:605:10)
at startup (bootstrap_node.js:158:16)
at bootstrap_node.js:575:3
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ 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
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @ watch script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/ryanmac51/.npm/_logs/2017-06-19T21_03_16_324Z-debug.log
Here is my debug file
0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/Cellar/node/8.1.2/bin/node',
1 verbose cli '/usr/local/bin/npm',
1 verbose cli 'run',
1 verbose cli 'watch' ]
2 info using [email protected]
3 info using [email protected]
4 verbose run-script [ 'prewatch', 'watch', 'postwatch' ]
5 info lifecycle @~prewatch: @
6 silly lifecycle @~prewatch: no script for prewatch, continuing
7 info lifecycle @~watch: @
8 verbose lifecycle @~watch: unsafe-perm in lifecycle true
9 verbose lifecycle @~watch: PATH: /usr/local/lib/node_modules/npm/bin/node-gyp-bin:/_local/krish/laravel/demo/node_modules/.bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/ryanmac51/.composer/vendor/bin
10 verbose lifecycle @~watch: CWD: /_local/krish/laravel/demo
11 silly lifecycle @~watch: Args: [ '-c',
11 silly lifecycle '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' ]
12 silly lifecycle @~watch: Returned: code: 1 signal: null
13 info lifecycle @~watch: Failed to exec watch script
14 verbose stack Error: @ 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
14 verbose stack Exit status 1
14 verbose stack at EventEmitter.
14 verbose stack at emitTwo (events.js:125:13)
14 verbose stack at EventEmitter.emit (events.js:213:7)
14 verbose stack at ChildProcess.
14 verbose stack at emitTwo (events.js:125:13)
14 verbose stack at ChildProcess.emit (events.js:213:7)
14 verbose stack at maybeClose (internal/child_process.js:897:16)
14 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:208:5)
15 verbose pkgid @
16 verbose cwd /_local/krish/laravel/demo
17 verbose Darwin 14.5.0
18 verbose argv "/usr/local/Cellar/node/8.1.2/bin/node" "/usr/local/bin/npm" "run" "watch"
19 verbose node v8.1.2
20 verbose npm v5.0.3
21 error code ELIFECYCLE
22 error errno 1
23 error @ 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
23 error Exit status 1
24 error Failed at the @ watch script.
24 error This is probably not a problem with npm. There is likely additional logging output above.
25 verbose exit [ 1, true ]
package.json
{
"private": true,
"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",
"watch-poll": "node node_modules/cross-env/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/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"
},
"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"
}
}
@krish-ryan Did you even read the release notes for v1.0
? You are supposed to remove cross-env
from the scripts.
@ruchern Thanks for reply, I am really new to this. But I've tried so many ways So would you like to share some link or pointers that i can use with it. appreciate it, Thanks.
@krish-ryan Hi, just remove cross-env
package by doing npm uninstall -D cross-env
and you should be good.
Also, remember to remove cross-env
from package.json
.
I read my previous message and I think the tone can be misleading. Sorry about that.
@ruchern Its all good mate.
But with npm uninstall -D cross-env
it didnt solve issue.
My package.json is like this now (just to make sure i update it right or not!)
{
"private": true,
"scripts": {
"dev": "node NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
"watch": "node 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_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_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_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.1.10"
}
}
and error becomes
node NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js
module.js:487
throw err;
^Error: Cannot find module '/_local/krish/laravel/demo/NODE_ENV=development'
at Function.Module._resolveFilename (module.js:485:15)
at Function.Module._load (module.js:437:25)
at Function.Module.runMain (module.js:605:10)
at startup (bootstrap_node.js:158:16)
at bootstrap_node.js:575:3
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ watch:node NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @ watch script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
According to your package.json, looks like cross env isn't installed. So either remove the cross env references from your scripts in package.json or install cross-env.
I copied main project files in to new laravel project and run npm install
again
It solve my problem.
Thank you guys.
@devcircus Why does he need to install cross-env
. @JeffreyWay Took it out in v1.0
https://github.com/JeffreyWay/laravel-mix/blob/master/docs/installation.md#npm-scripts
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.
So, natively, on the Mac at least, you need to manually remove references to cross-env
(or install it). An easy gotcha :( I wish that information could be placed somewhere more obvious (maybe a note on the default homepage if it detects an appropriate system?).
@turzaizsolt 's answer should fix things for everyone though. Just replace the appropriate part in package.json. Worked for me on a fresh install of the latest Laravel.
Running npm install solved my issue.
Anyone else running into this issue, it might also be related to the codepage settings. See issue https://github.com/npm/npm/issues/3858#issuecomment-64730272
Run command chcp 850
in your windows command console and re-run the npm command.
"npm install --save" fixed this problem for me.
npm install --save-dev cross-env
Most helpful comment
For me the quick solution was this