`npm run watch` 在 Laravel 5.4 中不起作用

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/41866944/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 17:37:51  来源:igfitidea点击:

`npm run watch` not working in Laravel 5.4

laravellaravel-5.4

提问by Josh Mountain

Using Laravel 5.4 and Mix, when I run npm run watchit compiles everything once and looks like it is waiting for changes, but when I make changes to any of my asset files it doesn't seem to detect anything. Is anyone else having this issue in 5.4 or have a solution?

使用 Laravel 5.4 和 Mix,当我运行npm run watch它时,它会编译所有内容,看起来它正在等待更改,但是当我对任何资产文件进行更改时,它似乎没有检测到任何内容。有没有其他人在 5.4 中有这个问题或有解决方案?

回答by Josh Mountain

The solution was provided by Jeffrey Way over at Laracasts.

解决方案是由 Jeffrey Way 在 Laracasts 提供的。

Try adding the --watch-poll flag to your package.jsonscript. Or just try:

尝试将 --watch-poll 标志添加到您的package.json脚本中。或者只是尝试:

node_modules/.bin/webpack --watch --watch-poll --config=node_modules/laravel-mix/setup/webpack.config.js

node_modules/.bin/webpack --watch --watch-poll --config=node_modules/laravel-mix/setup/webpack.config.js

回答by Atiar Rahman

npm run watch-poll

npm 运行监视轮询

It's working on ubuntu as well And auto compiling on code changes. Thank you.

它也适用于 ubuntu 并自动编译代码更改。谢谢你。

回答by Hussam Adil

npm run watch-poll

npm 运行监视轮询

watch-pollperiodically checks (polls) for changes e.g. every 1000ms it will manually check to see if any files have changed.

watch-poll定期检查(轮询)是否有更改,例如每 1000 毫秒,它将手动检查以查看是否有任何文件已更改。

what laraveldocs say?

什么laravel文档说的?

You may find that in certain environments Webpack isn't updating when your files change. If this is the case on your system, consider using the watch-poll command. You can read up on the docs for a more information about mix.

您可能会发现在某些环境中,当您的文件更改时,Webpack 不会更新。如果您的系统出现这种情况,请考虑使用 watch-poll 命令。您可以阅读文档以获取有关mix的更多信息。