I\'m trying to run npm run dev
for Laravel Mix and I get this error:
> @ dev D:\\projects\\ptcs
> cross-env NODE_ENV=development webpack -
Delete the node_modules
folder
Then you should run the commands:
npm install --no-bin-links
npm run dev
It's worked on my Laravel 5.5 and Windows.
Simply try running npm install
/ yarn
etc first before running npm start
/ yarn
start as @only4 mentioned, if you see this problem, as it means your .env
is not in sync with your package.json
, i.e. you installed a package but not quite configured it or other way around
You need to make cross-env working globally instead of having it in the project.
1) remove node_modules
folder
2) run
npm install --global cross-env
3) remove "cross-env": "^5.0.1",
from package.json
file devDependencies
section. Actually, you can skip this step and keep package.json intact. If you prefer.
4) run
npm install --no-bin-links
5) run
npm run dev
and see it working
P.S Tested on Windows 10 with Laravel-5.4
P.P.S Windows 10 with Laravel-5.6 does not have this problem, thus updating is an alternative solution.
You are getting the error because you might not have run the command npm install
first.
i.e.
First, run npm install
and then npm run dev
Your error states that cross-env is not installed.
'cross-env' is not recognized as an internal or external command, operable program or batch file.
You just need to run
npm install cross-env
The following worked for Laravel 7.x (and should probably work for any other version as well given the nature of the issue).
npm uninstall --save-dev cross-env
npm install -g cross-env
Just moving cross-env from being a local devDependency to a globally available package.