最近在使用webpack打包工具的时候,使用watch模式不管用,最开始以为是配置的问题,将就着写者,后面同一个项目在windows上可以,但是我用我的ubuntu运行watch模式怎么也不管用,通过google找到了解决方案。
解决方案
Debian,RedHat或其他类似的Linux发行版
echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
Arch Linux
echo fs.inotify.max_user_watches=524288 | sudo tee /etc/sysctl.d/40-max-user-watches.conf && sudo sysctl --system
在终端中输入上面的命令
Why?
这是因为在Linux下监控的文件有一定的限制,当我们项目的文件超过这个数量的时候,其他的文件就不会再监控,webpack无法监测到文件的变化,所以watch模式就失效了
使用下面命令可以查看限制的数量:
cat /proc/sys/fs/inotify/max_user_watches
参考
https://github.com/guard/listen/wiki/Increasing-the-amount-of-inotify-watchers
文章评论