伙计们,请你帮我解决这个问题,我在为我的Laravel Mix运行npm run dev时遇到了麻烦。我按照下面的链接但仍然存在错误。我的操作系统有问题吗?我尝试删除 node_modules ,运行 npm install --global cross-env 。并再次运行NPM安装。
https://github.com/JeffreyWay/laravel-mix/issues/478
Laravel 5.4 'cross-env' is not recognized as an internal or external command
以下是我的版本:
> @ development C:\xampp\htdocs\codetinerant > cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --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! @ 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\Garciano\AppData\Roaming\npm-cache\_logs\2018-02-17T10_08_34_901Z-debug.log
答案 0 :(得分:10)
首先,运行:
wcslen
然后运行命令
rm -rf node_modules
rm package-lock.json yarn.lock
npm cache clear --force
,然后您也可以
npm install cross-env
npm install
答案 1 :(得分:3)
您是否尝试按照dwoodward上Github issue建议的cross-env
的建议路径指定package.json
的路径?这包含在"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",
"watch": "node node_modules/cross-env/dist/bin/cross-env.js NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
"watch-poll": "node node_modules/cross-env/dist/bin/cross-env.js NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --watch-poll --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
"hot": "node node_modules/cross-env/dist/bin/cross-env.js NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js",
"production": "node node_modules/cross-env/dist/bin/cross-env.js NODE_ENV=production node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"
文件中:
cross-env
这可能在更新版本的Laravel中有所改变,但要点是您应该将node_modules/cross-env/dist/bin/cross-env.js
更改为even
。
答案 2 :(得分:0)
尝试将npm bin目录添加到系统路径
例如C:\Users\DELL\AppData\Local\Yarn\bin
答案 3 :(得分:0)
我有同样的问题。我通过卸载 节点,然后运行以下命令来解决该问题:
npm install -d