Linux:如何修复 Watchpack Error (watcher): Error: ENOSPC: System limit for number of file watchers reached
问题
在 Linux 上,你看到类似以下的错误消息:
watchpack_error_output.txt
Watchpack Error (watcher): Error: ENOSPC: System limit for number of file watchers reached, watch '/home/uli/dev/myproject/node_modules/@primeuix'解决方案
如果你的 IDE(如 Visual Studio Code)监视大型工作区(通常是 node_modules 目录),经常会遇到此错误。
通常只需增加限制即可:
increase_inotify_limits.sh
echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf
echo fs.inotify.max_user_instances=16384 | sudo tee -a /etc/sysctl.conf
echo fs.inotify.max_queued_events=32768 | sudo tee -a /etc/sysctl.conf
sudo sysctl -p不过我还建议配置 VS Code 不监视这些路径:
- 打开
Preferences -> Open User Settings (JSON)并添加以下内容:
vscode_watcher_settings.json
"files.watcherExclude": {
"**/node_modules/**": true,
"**/dist/**": true,
"**/.git/**": true
}按类别查看类似文章:
Linux
如果这篇文章对您有帮助,请考虑请我喝杯咖啡或通过 PayPal 捐款,以支持 TechOverflow 上新文章的研究与发布