首頁 > 軟體

Fedora&Ubuntu 下使用gulp 報錯 Error: watch ENOSPC 解決方案

2020-06-16 17:45:57

Fedora&Ubuntu 下使用gulp 報錯 Error: watch ENOSPC 解決方案

用gulp啟動,錯誤如下

Error: watch ENOSPC
 at exports._errnoException (util.js:746:11)
 at FSWatcher.start (fs.js:1172:11)
 at Object.fs.watch (fs.js:1198:11)
 at Gaze._watchDir (/home/ajaxGu/work/froad/anhui-standard/personal-h5/node_modules/gulp/node_modules/vinyl-fs/node_modules/glob-watcher/node_modules/gaze/lib/gaze.js:289:30)
 at /home/ajaxGu/work/froad/anhui-standard/personal-h5/node_modules/gulp/node_modules/vinyl-fs/node_modules/glob-watcher/node_modules/gaze/lib/gaze.js:358:10
 at iterate (/home/ajaxGu/work/froad/anhui-standard/personal-h5/node_modules/gulp/node_modules/vinyl-fs/node_modules/glob-watcher/node_modules/gaze/lib/helper.js:52:5)
 at Object.forEachSeries (/home/ajaxGu/work/froad/anhui-standard/personal-h5/node_modules/gulp/node_modules/vinyl-fs/node_modules/glob-watcher/node_modules/gaze/lib/helper.js:66:3)
 at Gaze._initWatched (/home/ajaxGu/work/froad/anhui-standard/personal-h5/node_modules/gulp/node_modules/vinyl-fs/node_modules/glob-watcher/node_modules/gaze/lib/gaze.js:354:10)
 at Gaze.add (/home/ajaxGu/work/froad/anhui-standard/personal-h5/node_modules/gulp/node_modules/vinyl-fs/node_modules/glob-watcher/node_modules/gaze/lib/gaze.js:177:8)
 at new Gaze (/home/ajaxGu/work/froad/anhui-standard/personal-h5/node_modules/gulp/node_modules/vinyl-fs/node_modules/glob-watcher/node_modules/gaze/lib/gaze.js:74:10)

解決方案:
當前問題主要是因為gulp的watch需要監聽很多檔案的改動,但是fedora、ubuntu系統的檔案控制代碼其實是有限制的,因此可以使用以下命令:
echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p

親測可以使用,如果對你有用的話,麻煩推薦下,共勉之,謝謝。

本文永久更新連結地址http://www.linuxidc.com/Linux/2016-02/128711.htm


IT145.com E-mail:sddin#qq.com