Hitendra
Hitendra

Reputation: 3226

Laravel getting error in npm run dev command

I am getting below error while running

'npm run dev'

command.

> cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --p
rogress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js


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

npm ERR! Windows_NT 6.1.7601
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\
node_modules\\npm\\bin\\npm-cli.js" "run" "watch"
npm ERR! node v6.11.4
npm ERR! npm  v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! @ watch: `cross-env NODE_ENV=development node_modules/webpack/bin/webpa
ck.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 'cross-env NODE_ENV=development node_modul
es/webpack/bin/webpack.js --watch --progress --hide-modules --config=node_module
s/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
--watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpac
k.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.

Can anybody tell me what is the issue here? Thanks

Upvotes: 1

Views: 1479

Answers (2)

Carliyke
Carliyke

Reputation: 47

First you need to perform the following steps

  • rm -rf node_modules
  • rm package-lock.json yarn.lock
  • npm cache clear --force
  • npm install --global cross-env
  • npm install

Then try restarting your terminal and make sure you are not using the integrated terminal (e.g on visual studio code) when running "npm run dev". Instead, try running the "npm run dev" command on a different powershell terminal window. Works for me everytime.

Upvotes: 1

Alexey Mezenin
Alexey Mezenin

Reputation: 163748

I've had the same issue recently after upgrading Laravel app. You just need to install the package:

npm install cross-env

Upvotes: 4

Related Questions