laravel 5.4 dev npm run dev error

Published 1 year ago by w1n78

i wanted to get an early start before the release of laravel 5.4. so i downloaded a fresh copy onto an empty project. as i start to go through my usual configs, i noticed no more gulpfile.js. i checked out https://github.com/laravel/docs/blob/5.4/mix.md and seen a few commands

// Run all Mix tasks...
npm run dev

// Run all Mix tasks and minify output...
npm run production

so i guess no more gulp command. i ran the commands above and get the following errors.

> @ dev /Users/sherwin/apps/laravel/test_project
> cross-env NODE_ENV=development webpack --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js

sh: cross-env: command not found

npm ERR! Darwin 16.3.0
npm ERR! argv "/usr/local/Cellar/node/7.3.0/bin/node" "/usr/local/bin/npm" "run" "dev"
npm ERR! node v7.3.0
npm ERR! npm  v3.10.10
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! @ dev: `cross-env NODE_ENV=development webpack --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js`
npm ERR! spawn ENOENT
npm ERR! 
npm ERR! Failed at the @ dev script 'cross-env NODE_ENV=development webpack --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 webpack --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js

as you can see from the error, i have node and npm installed. i am the worst at anything node related and javascript. all of the files are unmodified except i added a laravel-debugbar repo and "app/Modles" in my autoload entry in composer.json. did i miss something?

Best Answer (As Selected By w1n78)
w1n78

woke up this morning and laravel 5.4 is released. i deleted my test project and pulled in the master branch. did the same thing but got a different error. looks like something to do with babel so i deleted ~/.babelrc and it no works :)

ejdelmonico

Inside the webpack.config.js is your replacement code for the gulpfile. If you need more customization, just copy the base file from mix. The commands are located in the package.json for npm. Your error message would indicate either a bad npm install or you are not running the command from the project root.

w1n78
w1n78
1 year ago (21,605 XP)

@ejdelmonico thanks for the help. could you please elaborate more. i found the node_modules/laravel-mix/setup/webpack.config.js file. still a bit confused.

am i supposed to take the contents of this and create a new gulpfile.js?

am i supposed to copy "dev": "cross-env NODE_ENV=development webpack --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js" and add it to webpack.mix.js?

as i mentioned, node and javascript are a weakness of mine and i'm still trying to get a better understanding of it. i am running the command from the project root.

should i delete node_modules and run npm install again?

ejdelmonico

Hold on a sec. I will try a new install because a lot has changed in a month.

ejdelmonico

@w1n78 I had the sam exact issue with new install. I installed cross-env, webpack and babel globally and it works fine now.

yarn add webpack babel cross-env

That should fix it. Don't forget to include a .babelrc with

{
    "presets": ["es2015"]
}
w1n78
w1n78
1 year ago (21,605 XP)

@ejdelmonico i installed those 3 and created .babelrc in the project root. do i have to initialize .babelrc or source it?

i get the following errors now...

> @ dev /Users/sherwin/apps/laravel/test_project
> cross-env NODE_ENV=development webpack --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js

 73% optimize/Users/sherwin/apps/laravel/test_project/node_modules/extract-text-webpack-plugin/index.js:246
                var shouldExtract = !!(options.allChunks || chunk.isInitial());
                                                                  ^

TypeError: chunk.isInitial is not a function
    at /Users/sherwin/apps/laravel/test_project/node_modules/extract-text-webpack-plugin/index.js:246:55
    at /Users/sherwin/apps/laravel/test_project/node_modules/extract-text-webpack-plugin/node_modules/async/dist/async.js:3025:16
    at eachOfArrayLike (/Users/sherwin/apps/laravel/test_project/node_modules/extract-text-webpack-plugin/node_modules/async/dist/async.js:941:9)
    at eachOf (/Users/sherwin/apps/laravel/test_project/node_modules/extract-text-webpack-plugin/node_modules/async/dist/async.js:991:5)
    at Object.eachLimit (/Users/sherwin/apps/laravel/test_project/node_modules/extract-text-webpack-plugin/node_modules/async/dist/async.js:3089:3)
    at ExtractTextPlugin.<anonymous> (/Users/sherwin/apps/laravel/test_project/node_modules/extract-text-webpack-plugin/index.js:244:10)
    at Compilation.applyPluginsAsync (/Users/sherwin/apps/laravel/test_project/node_modules/tapable/lib/Tapable.js:71:13)
    at Compilation.seal (/Users/sherwin/apps/laravel/test_project/node_modules/webpack/lib/Compilation.js:525:7)
    at Compiler.<anonymous> (/Users/sherwin/apps/laravel/test_project/node_modules/webpack/lib/Compiler.js:397:15)
    at /Users/sherwin/apps/laravel/test_project/node_modules/tapable/lib/Tapable.js:103:11
    at Compilation.<anonymous> (/Users/sherwin/apps/laravel/test_project/node_modules/webpack/lib/Compilation.js:445:10)
    at /Users/sherwin/apps/laravel/test_project/node_modules/webpack/lib/Compilation.js:417:12
    at /Users/sherwin/apps/laravel/test_project/node_modules/webpack/lib/Compilation.js:332:10
    at /Users/sherwin/apps/laravel/test_project/node_modules/async/lib/async.js:52:16
    at done (/Users/sherwin/apps/laravel/test_project/node_modules/async/lib/async.js:246:17)
    at /Users/sherwin/apps/laravel/test_project/node_modules/async/lib/async.js:44:16
    at errorAndCallback (/Users/sherwin/apps/laravel/test_project/node_modules/webpack/lib/Compilation.js:202:5)
    at errorOrWarningAndCallback (/Users/sherwin/apps/laravel/test_project/node_modules/webpack/lib/Compilation.js:225:13)
    at /Users/sherwin/apps/laravel/test_project/node_modules/webpack/lib/Compilation.js:229:12
    at onDoneResolving (/Users/sherwin/apps/laravel/test_project/node_modules/webpack/lib/NormalModuleFactory.js:29:20)
    at /Users/sherwin/apps/laravel/test_project/node_modules/webpack/lib/NormalModuleFactory.js:85:20
    at /Users/sherwin/apps/laravel/test_project/node_modules/async/lib/async.js:726:13
    at /Users/sherwin/apps/laravel/test_project/node_modules/async/lib/async.js:52:16
    at done (/Users/sherwin/apps/laravel/test_project/node_modules/async/lib/async.js:241:17)
    at /Users/sherwin/apps/laravel/test_project/node_modules/async/lib/async.js:44:16
    at /Users/sherwin/apps/laravel/test_project/node_modules/async/lib/async.js:723:17
    at /Users/sherwin/apps/laravel/test_project/node_modules/async/lib/async.js:167:37
    at /Users/sherwin/apps/laravel/test_project/node_modules/enhanced-resolve/lib/UnsafeCachePlugin.js:24:19
    at onResolved (/Users/sherwin/apps/laravel/test_project/node_modules/enhanced-resolve/lib/Resolver.js:38:18)
    at /Users/sherwin/apps/laravel/test_project/node_modules/enhanced-resolve/lib/Resolver.js:127:10

then the same errors appear as above. wonder if it's because i'm using a dev branch that i have to also point to dependencies' dev branches. although, you were able to fix it.

w1n78
w1n78
1 year ago (21,605 XP)

@ejdelmonico i deleted my node_modules and tried again. also moved .babelrc to ~/.babelrc. i tried to source it but error so i guess i don't source it. same error.

any other ideas? BTW thanks for your time and patience.

w1n78
w1n78
1 year ago (21,605 XP)

woke up this morning and laravel 5.4 is released. i deleted my test project and pulled in the master branch. did the same thing but got a different error. looks like something to do with babel so i deleted ~/.babelrc and it no works :)

dev_hernandez2

I have the same error

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

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 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:
KrzysztofNiepokojczycki

@dev_hernandez2 , I had the same error. Fixed it by removing the paths and .js suffix, so that now my script looks like:

cross-env NODE_ENV=development webpack --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js

Demers94

I was having the same problem, and tweaking the paths like @KrzysztofNiepokojczycki did fixed it.

It would be great if there was a better way to solve this, I'd rather not have to do this for every new project.

bajro17
bajro17
1 year ago (13,090 XP)

@KrzysztofNiepokojczycki Thanks it fix :)

dev_hernandez2

Thanks @KrzysztofNiepokojczycki but still have the error.

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

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 v6.9.4
npm ERR! npm  v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! @ dev: `cross-env NODE_ENV=development webpack --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 webpack --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 webpack --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:
DeanKH
DeanKH
1 year ago (13,910 XP)

Same error here. Running npm run dev gives me the errors posted above, however, if I take the command and run it manually:

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

It seems to work without issue. Any ideas on how to fix this?

lorvent
lorvent
1 year ago (14,235 XP)

after following those 2 steps, now my npm run dev running

but throwing another error

> cross-env NODE_ENV=development webpack --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js
                                                                           73% optimizeD:\xampp\htdocs\josh_laravel54\node_modules\extract-text-webpack-plugin\index.js:246
                                var shouldExtract = !!(options.allChunks || chunk.isInitial());
                                                                                  ^

TypeError: chunk.isInitial is not a function
    at D:\xampp\htdocs\josh_laravel54\node_modules\extract-text-webpack-plugin\index.js:246:55
    at D:\xampp\htdocs\josh_laravel54\node_modules\extract-text-webpack-plugin\node_modules\async\dist\async.js:3025:16
    at eachOfArrayLike (D:\xampp\htdocs\josh_laravel54\node_modules\extract-text-webpack-plugin\node_modules\async\dist\async.js:941:9)
    at eachOf (D:\xampp\htdocs\josh_laravel54\node_modules\extract-text-webpack-plugin\node_modules\async\dist\async.js:991:5)
    at Object.eachLimit (D:\xampp\htdocs\josh_laravel54\node_modules\extract-text-webpack-plugin\node_modules\async\dist\async.js:3089:3)
    at ExtractTextPlugin.<anonymous> (D:\xampp\htdocs\josh_laravel54\node_modules\extract-text-webpack-plugin\index.js:244:10)
    at Compilation.applyPluginsAsync (D:\xampp\htdocs\josh_laravel54\node_modules\tapable\lib\Tapable.js:71:13)
    at Compilation.seal (D:\xampp\htdocs\josh_laravel54\node_modules\webpack\lib\Compilation.js:525:7)
    at Compiler.<anonymous> (D:\xampp\htdocs\josh_laravel54\node_modules\webpack\lib\Compiler.js:397:15)
    at D:\xampp\htdocs\josh_laravel54\node_modules\tapable\lib\Tapable.js:103:11
    at Compilation.<anonymous> (D:\xampp\htdocs\josh_laravel54\node_modules\webpack\lib\Compilation.js:445:10)
    at D:\xampp\htdocs\josh_laravel54\node_modules\webpack\lib\Compilation.js:417:12
    at D:\xampp\htdocs\josh_laravel54\node_modules\webpack\lib\Compilation.js:332:10
    at D:\xampp\htdocs\josh_laravel54\node_modules\async\lib\async.js:52:16
    at done (D:\xampp\htdocs\josh_laravel54\node_modules\async\lib\async.js:246:17)
    at D:\xampp\htdocs\josh_laravel54\node_modules\async\lib\async.js:44:16
    at errorAndCallback (D:\xampp\htdocs\josh_laravel54\node_modules\webpack\lib\Compilation.js:202:5)
    at errorOrWarningAndCallback (D:\xampp\htdocs\josh_laravel54\node_modules\webpack\lib\Compilation.js:225:13)
    at D:\xampp\htdocs\josh_laravel54\node_modules\webpack\lib\Compilation.js:229:12
    at onDoneResolving (D:\xampp\htdocs\josh_laravel54\node_modules\webpack\lib\NormalModuleFactory.js:29:20)
    at D:\xampp\htdocs\josh_laravel54\node_modules\webpack\lib\NormalModuleFactory.js:85:20
    at D:\xampp\htdocs\josh_laravel54\node_modules\async\lib\async.js:726:13
    at D:\xampp\htdocs\josh_laravel54\node_modules\async\lib\async.js:52:16
    at done (D:\xampp\htdocs\josh_laravel54\node_modules\async\lib\async.js:241:17)
    at D:\xampp\htdocs\josh_laravel54\node_modules\async\lib\async.js:44:16
    at D:\xampp\htdocs\josh_laravel54\node_modules\async\lib\async.js:723:17
    at D:\xampp\htdocs\josh_laravel54\node_modules\async\lib\async.js:167:37
    at D:\xampp\htdocs\josh_laravel54\node_modules\enhanced-resolve\lib\UnsafeCachePlugin.js:24:19
    at onResolved (D:\xampp\htdocs\josh_laravel54\node_modules\enhanced-resolve\lib\Resolver.js:38:18)
    at D:\xampp\htdocs\josh_laravel54\node_modules\enhanced-resolve\lib\Resolver.js:127:10

npm ERR! Windows_NT 6.1.7601
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\Seenu\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "run" "dev"
npm ERR! node v6.9.4
npm ERR! npm  v4.1.1
npm ERR! code ELIFECYCLE
npm ERR! @ dev: `cross-env NODE_ENV=development webpack --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 webpack --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 webpack --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!     D:\xampp\htdocs\josh_laravel54\npm-debug.log

looks like mix is immature yet,

anyone recommend using gulp/elixir or stick to mix and wait till bugs fixed?

thanks

TaylorOtwell

Can you all try with the latest package.json in the laravel/laravel repository:

https://github.com/laravel/laravel/blob/master/package.json

Please sign in or create an account to participate in this conversation.