Laravel 5.4"cross-env"未被识别为内部或外部命令 [英] Laravel 5.4 ‘cross-env’ Is Not Recognized as an Internal or External Command
问题描述
我正在尝试为Laravel Mix运行npm run dev
,但出现此错误:
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 --progress --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! code ELIFECYCLE
npm ERR! errno 1
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.
我将node.js更新为6.11.0,将npm更新为5.2.0,但这没有帮助.我在Windows 7上运行Homestead.
I updated node.js to 6.11.0 and npm to 5.2.0, but it didn't help. I'm running Homestead on Windows 7.
推荐答案
您需要使cross-env全局运行,而不是在项目中使用它.
You need to make cross-env working globally instead of having it in the project.
1)删除 node_modules
文件夹
1) remove node_modules
folder
2)运行
npm install --global cross-env
npm install --global cross-env
3)从package.json
文件devDependencies
部分中删除"cross-env": "^5.0.1",
.实际上,您可以跳过此步骤,并保持package.json不变.如果您愿意.
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)运行
npm install --no-bin-links
npm install --no-bin-links
5)运行
npm run dev
看到它正常工作
PS在Windows 10上使用Laravel-5.4测试
P.P.S Windows 10不会出现此问题,因此更新是另一种解决方案.
P.P.S Windows 10 with Laravel-5.6 does not have this problem, thus updating is an alternative solution.
这篇关于Laravel 5.4"cross-env"未被识别为内部或外部命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!