当我这样做时 ng serve
日志显示如下错误:
Error from chokidar (/PATH_OF_MY_PROJECT/node_modules/ionicons/dist/ionicons/svg): Error: ENOSPC: System limit for number of file watchers reached, watch '/PATH_OF_MY_PROJECT/node_modules/ionicons/dist/ionicons/svg/ios-subway.svg'
我读到解决方案是在 Linux 上更改观察者文件,但这是一个糟糕的解决方案!为什么 Angular 需要查看
node_modules
的变化?这是一个不会改变的文件夹。如果我需要安装一个新库,我可以重新启动服务器。如果您的解决方案是:
echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf
.我不想使用这个糟糕的解决方案。
最佳答案
我遇到了同样的问题,每个答案都指向了您所说的解决方案。
Doesnt answer me if your solution is: echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf
这也没有帮助我。
我找不到解决方案,但是在 webpack 中,您可以忽略/排除您不想检查的目录,只需在 module.exports 中执行以下操作即可:
module.exports = {
target: 'node',
...
watchOptions: {
ignored: [
/node_modules/,
...
],
},
关于angular-cli - 如何从观察者文件中排除 node_modules,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62212835/