Laravel-mix: npm run dev fails on my 5.4 when configuring passport API Authentication

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

$ npm run dev

@ dev C:\xampp\htdocs\TocApp
cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js

The system cannot find the path specified.
events.js:160
throw er; // Unhandled 'error' event
^

Error: spawn node_modules/webpack/bin/webpack.js ENOENT
at notFoundError (C:\xampp\htdocs\TocAppnode_modules\cross-spawn\libenoent.js:11:11)
at verifyENOENT (C:\xampp\htdocs\TocAppnode_modules\cross-spawn\libenoent.js:46:16)
at ChildProcess.cp.emit (C:\xampp\htdocs\TocAppnode_modules\cross-spawn\libenoent.js:33:19)
at Process.ChildProcess._handle.onexit (internal/child_process.js:215:12)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ dev: cross-env 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 'cross-env 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! cross-env 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! A complete log of this run can be found in:
npm ERR! C:\Users\BRAYAN\AppData\Roaming\npm-cache_logs\2017-03-27T08_28_13_634Z-debug.log

Most helpful comment

I had this issue i did the following steps and i have no issues anymore:

  1. Delete node_modules directory
  2. Detete package-lock.json file -> very important
  3. Run npm install
  4. Run npm run dev

My details:

npm -v => 5.0.3
node -v => v8.1.4

"laravel-mix": "^1.2.1",
"cross-env": "^5.0.1",
"vue": "^2.4.1",

All 24 comments

@Brayantezz
Can you follow ISSSUE_TEMPLATE.md and answer those question.
This way we can help and debug better.

Yep - we need the issue template filled out.

Hi @JeffreyWay @ankurk91
I'm having the same issue:

Laravel Mix Version: 5.4.16
Node Version (node -v): 4.4.0
NPM Version (npm -v): 2.14.20
OS: Windows 10

Description:

When i run npm run dev, i'm receiving an error:

> @ dev D:\OpenServer\domains\adtool
> cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js

System cannot find the path specified.
events.js:141
      throw er; // Unhandled 'error' event
      ^

Error: spawn node_modules/webpack/bin/webpack.js ENOENT
    at notFoundError (D:\OpenServer\domains\adtool\node_modules\cross-env\node_modules\cross-spawn\lib\enoent.js:11:11)
    at verifyENOENT (D:\OpenServer\domains\adtool\node_modules\cross-env\node_modules\cross-spawn\lib\enoent.js:46:16)
    at ChildProcess.cp.emit (D:\OpenServer\domains\adtool\node_modules\cross-env\node_modules\cross-spawn\lib\enoent.js:33:19)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12)

npm ERR! Windows_NT 10.0.14393
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "dev"
npm ERR! node v4.4.0
npm ERR! npm  v2.14.20
npm ERR! code ELIFECYCLE
npm ERR! @ dev: `cross-env 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 'cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js'.
npm ERR! 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!     cross-env 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 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!     D:\OpenServer\domains\adtool\npm-debug.log

File node_modules/webpack/bin/webpack.js not exists. Path node_modules/webpack not exists as well.

Steps To Reproduce:

Clean laravel instalation, then:
1) run composer install;
2) run npm install;
3) run npm install cross-env -D (read it from https://github.com/laravel/framework/issues/18446);
3) run npm run dev.

Solution:

@Brayantezz
Node.js version was too old. After i installed Node.js 7.7.4, and reinstalled node_modules all works fine.

Confirm, Just tried with:

  • Laravel mix v0.9.2
  • node v4.8.1
  • npm v2.15.11
  • OS: Ubuntu 16.04 x64
npm run dev

Produce this error

> racecloud-devDependencies@ dev /home/ankurk/projects/race-cloud
> 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

/home/ankurk/projects/race-cloud/node_modules/laravel-mix/setup/webpack.config.js:1
(function (exports, require, module, __filename, __dirname) { let path = require('path');
                                                              ^^^

SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode
    at exports.runInThisContext (vm.js:53:16)
    at Module._compile (module.js:373:25)
    at Object.Module._extensions..js (module.js:416:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
    at requireConfig (/home/ankurk/projects/race-cloud/node_modules/webpack/bin/convert-argv.js:96:18)
    at /home/ankurk/projects/race-cloud/node_modules/webpack/bin/convert-argv.js:109:17
    at Array.forEach (native)

npm ERR! Linux 4.4.0-57-generic
npm ERR! argv "/home/ankurk/.nvm/versions/node/v4.8.1/bin/node" "/home/ankurk/.nvm/versions/node/v4.8.1/bin/npm" "run" "dev"
npm ERR! node v4.8.1
npm ERR! npm  v2.15.11
npm ERR! code ELIFECYCLE
npm ERR! racecloud-devDependencies@ 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 racecloud-devDependencies@ 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! This is most likely a problem with the racecloud-devDependencies 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 racecloud-devDependencies
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! 
npm ERR!     npm owner ls racecloud-devDependencies
npm ERR! There is likely additional logging output above.

@JeffreyWay
Should we also specify minimum node js version in readme.md ?
OR
We can add something like this to package.json

"engines": {
    "node": ">=6.10.1",
    "npm": ">=3.10.10"
  },
  "engineStrict": true,

This way npm will refuse to install laravel-mix if suitable node version is not installed on machine.
Read more about engines here
OR
We can bother Travis-CI to run some tests on different version of node.

P.S.
Node version requirements is already defined in package.json

i did a fresh installation of laravel updated my node and npm and all worked fine,followed these steps

run composer install;
run npm install;
run npm install cross-env -D (read it from laravel/framework#18446);
run npm run dev.

Thanks, it works!. @Brayantezz

Tried @Brayantezz method but didn't worked. I fixed it by requiring webpack in my local package.json file. Even though I had it installed globally.

@jrmorales can you post a sample of the require in package.json?

I gotta say @JeffreyWay I found gulp to be way easier. I'm having a hell of a time getting mix to work,

@dk4210 Then use Gulp. Or, create a new issue and explain what specifically you're having trouble with. It's almost always related to a faulty install.

Do you have a tutorial on how to switch to gulp? Forgive me I'm just a beginner.

@JeffreyWay this is my error and log if that helps.

PS C:\xampp\htdocs\automation_team> npm run dev

@ dev C:\xampp\htdocs\automation_team
npm run development

npm WARN invalid config loglevel="notice"

@ development C:\xampp\htdocs\automation_team
cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/lar
avel-mix/setup/webpack.config.js

C:\xampp\htdocs\automation_teamnode_moduleslaravel-mix\setupwebpack.config.js:24
let WebpackConfig = require('../src/builder/WebpackConfig');
^^^

SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:374:25)
at Object.Module._extensions..js (module.js:417:10)
at Module.load (module.js:344:32)
at Function.Module._load (module.js:301:12)
at Module.require (module.js:354:17)
at require (internal/module.js:12:17)
at requireConfig (C:\xampp\htdocs\automation_teamnode_moduleswebpack\bin\convert-argv.js:97:18)
at C:\xampp\htdocs\automation_teamnode_moduleswebpack\bin\convert-argv.js:104:17
at Array.forEach (native)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ development: cross-env 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 @ development 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! C:\Users\name\AppData\Roaming\npm-cache_logs\2017-07-13T15_04_05_713Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ dev: npm run development
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @ dev 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! C:\Users\name\AppData\Roaming\npm-cache_logs\2017-07-13T15_04_05_745Z-debug.log
PS C:\xampp\htdocs\automation_team>

-----------------------------------Log File ------------------------------------------------------------

0 info it worked if it ends with ok
1 verbose cli [ 'C:\Program Files\nodejs\node.exe',
1 verbose cli 'C:\Users\name\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js',
1 verbose cli 'run',
1 verbose cli 'dev' ]
2 info using [email protected]
3 info using [email protected]
4 verbose run-script [ 'predev', 'dev', 'postdev' ]
5 info lifecycle @~predev: @
6 info lifecycle @~dev: @
7 verbose lifecycle @~dev: unsafe-perm in lifecycle true
8 verbose lifecycle @~dev: PATH: C:\Users\name\AppData\Roaming\npmnode_modules\npm\bin\node-gyp-bin;C:\xampp\htdocs\automation_teamnode_modules.bin;%SystemRoot%\system32\WindowsPowerShellv1.0\;C:\ProgramData\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\WindowsSystem32\Wbem;C:\WindowsSystem32\WindowsPowerShellv1.0\;c:\Program Files (x86)\Microsoft SQL Server100\Tools\Binn\VSShell\Common7\IDE\;c:\Program Files (x86)\Microsoft SQL Server100\Tools\Binn\;c:\Program Files\Microsoft SQL Server100\Tools\Binn\;c:\Program Files (x86)\Microsoft SQL Server100\DTS\Binn\;c:\Program Files (x86)\Microsoft SQL Server110\Tools\Binn\ManagementStudio\;c:\Program Files (x86)\Microsoft SQL Server110\Tools\Binn\;c:\Program Files\Microsoft SQL Server110\Tools\Binn\;c:\Program Files (x86)\Microsoft SQL Server110\DTS\Binn\;C:\Program Files (x86)\WinMerge;C:\Program Files\Java\jdk1.7.0_51\bin;D:\work\apache-maven-3.1.1\bin;C:\Program Files\TortoiseSVN\bin;C:\Program Files\nodejs\;C:\xampp\php;D:\work\springsource\spring-roo-1.2.5.RELEASE\bin;C:\ProgramData\ComposerSetup\bin;C:\Program Files\Git\cmd;C:\Users\dkelly-a\AppData\Roaming\Composer\vendor\bin
9 verbose lifecycle @~dev: CWD: C:\xampp\htdocs\automation_team
10 silly lifecycle @~dev: Args: [ '/d /s /c', 'npm run development' ]
11 silly lifecycle @~dev: Returned: code: 1 signal: null
12 info lifecycle @~dev: Failed to exec dev script
13 verbose stack Error: @ dev: npm run development
13 verbose stack Exit status 1
13 verbose stack at EventEmitter. (C:\Users\name\AppData\Roaming\npmnode_modules\npm\lib\utils\lifecycle.js:289:16)
13 verbose stack at emitTwo (events.js:87:13)
13 verbose stack at EventEmitter.emit (events.js:172:7)
13 verbose stack at ChildProcess. (C:\Users\name\AppData\Roaming\npmnode_modules\npm\lib\utils\spawn.js:40:14)
13 verbose stack at emitTwo (events.js:87:13)
13 verbose stack at ChildProcess.emit (events.js:172:7)
13 verbose stack at maybeClose (internal/child_process.js:821:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5)
14 verbose pkgid @
15 verbose cwd C:\xampp\htdocs\automation_team
16 verbose Windows_NT 6.1.7601
17 verbose argv "C:\Program Files\nodejs\node.exe" "C:\Users\name\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js" "run" "dev"
18 verbose node v4.2.6
19 verbose npm v5.2.0
20 error code ELIFECYCLE
21 error errno 1
22 error @ dev: npm run development
22 error Exit status 1
23 error Failed at the @ dev script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]

Thanks,
Dan

Hey, Dan -

Please create a new GitHub issue and fill out the template so that we can help. I can't offer any ideas without knowing what version of Mix you have installed, and what your webpack.mix.js file looks like.

But based on this block-scope error you're seeing here:

let WebpackConfig = require('../src/builder/WebpackConfig');

I'm thinking you have an ancient version of Node installed.

I had this issue i did the following steps and i have no issues anymore:

  1. Delete node_modules directory
  2. Detete package-lock.json file -> very important
  3. Run npm install
  4. Run npm run dev

My details:

npm -v => 5.0.3
node -v => v8.1.4

"laravel-mix": "^1.2.1",
"cross-env": "^5.0.1",
"vue": "^2.4.1",

Hi @JeffreyWay I think it may be best if I can just convert over to gulp. Everything I've tried wont work. I even followed @hassanazimi instructions but still no luck. I updated my node to version 6.11.1
My npm is 5.2.0
I dont know how to find the Laravel Mix Version. I ran the command npm list --depth=0 but I get a lot of "Missing" errors.

I need to compile my css files but can't.
Thanks,
Dan

what error are you getting @dk4210 ? I can see your node version is old.

Upgraded to 6.11.1
Thanks!

On Jul 13, 2017 2:05 PM, "Amir Hassan Azimi" notifications@github.com
wrote:

what error are you getting @dk4210 https://github.com/dk4210 ? I can
see your node version is old.

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/JeffreyWay/laravel-mix/issues/623#issuecomment-315156951,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ABGELpT-wdhbAlmZtjmM3xS404TCph6dks5sNlxsgaJpZM4Mp8d6
.

You probably need node 8 for some of these new loaders to work.

I got this problem too. My node version is 6.9.1 and npm is 3.10.8 with Windows OS 64-bit.
I reinstall the laravel project and installing the newest using command composer create-project --prefer-dist laravel/laravel myproject.Now, it worked perfectly.

I notice that cross-env is required for running the laravel-mix

@korneliuskristianr

I notice that cross-env is required for running the laravel-mix

Only for Windows so far. Mac and Linux works fine without.

I had the same issue as @Brayantezz. I updated to the latest node version and it fixed all the problems.

It would be super sweet if the Laravel docs had a min version requirement for node/npm. Updating these solved my problem too. Maybe it does and I'm just missing it?

@hassanazimi sol'n worked for me. thanks, mate.

I had this issue i did the following steps and i have no issues anymore:

  1. Delete node_modules directory
  2. Detete package-lock.json file -> very important
  3. Run npm install
  4. Run npm run dev

My details:

npm -v => 5.0.3
node -v => v8.1.4

"laravel-mix": "^1.2.1",
"cross-env": "^5.0.1",
"vue": "^2.4.1",

Cheers mate, that worked

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mementoneli picture mementoneli  Â·  3Comments

terion-name picture terion-name  Â·  3Comments

mstralka picture mstralka  Â·  3Comments

dtheb picture dtheb  Â·  3Comments

sdebacker picture sdebacker  Â·  3Comments