npm run watch在Laravel 6.0中不起作用

时间:2020-01-22 03:19:01

标签: node.js laravel npm laravel-6 laravel-6.2

我正在观看此视频https://www.youtube.com/watch?v=zEPYSNO7o3Q

我在npm run dev中遇到了错误

这是我尝试的解决方案:

Step1: composer update
Step2: rm -rf node_modules
Step3: npm cache clean
Step4: npm install
Step5: npm outdated
Step6: npm install
Step7: npm run dev

但是我仍然收到此错误:

> @ development C:\laragon\www\lara6
> 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\mmagante\AppData\Roaming\npm-cache\_logs\2020-01-22T03_04_02_064Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ dev: `npm run development`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @ dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

我当前正在使用:

php artisan --version -Laravel Framework 6.12.0

节点-v -v12.14.1

npm -v -6.13.6

php -v -PHP 7.2.19

我也找到了此链接,但仍然无法正常工作: https://github.com/JeffreyWay/laravel-mix/issues/1072

2 个答案:

答案 0 :(得分:0)

有一个类似的问题,npm run watch在我的终端上不起作用,但没有给出类似的错误。可能您可能需要先安装/重新安装cross-env。

npm安装交叉环境

如果npm run watch之后仍然无法正常运行,但没有错误,请尝试以下操作:

  1. 再次安装webpack(无需删除)

npm安装webpack

  1. 在package.json中,替换

“ watch”:“ npm运行开发---watch”,

使用

“ watch”:“跨环境NODE_ENV =开发node_modules / webpack / bin / webpack.js --watch --progress --hide-modules --config = node_modules / laravel-mix / setup / webpack.config。 js”,

可能不需要执行步骤1。只需张贴我为使之正常工作而执行的步骤。希望这对某人有所帮助,因为我已经有一段时间在stackoverflow上获得了很好的答案,有时间我会尽力回馈。

答案 1 :(得分:0)

从项目中删除node_modules文件夹。

运行npm install --global cross-env此命令。

"cross-env": "^5.0.1",文件package.json部分删除devDependencies

运行npm install --no-bin-links

现在运行npm run dev