docusaurusを確認していたら以下のようなエラーが出てきた。
Error from chokidar (/home/vagrant/tmp/20201121/my-website/static/img): Error: ENOSPC: System limit for number of file watchers reached, watch '/home/vagrant/tmp/20201121/my-website/static/img/undraw_docusaurus_mountain.svg' Error from chokidar (/home/vagrant/tmp/20201121/my-website/static/img): Error: ENOSPC: System limit for number of file watchers reached, watch '/home/vagrant/tmp/20201121/my-website/static/img/undraw_docusaurus_react.svg' Error from chokidar (/home/vagrant/tmp/20201121/my-website/static/img): Error: ENOSPC: System limit for number of file watchers reached, watch '/home/vagrant/tmp/20201121/my-website/static/img/undraw_docusaurus_tree.svg'
何なのかがよくわからんかったので調べてみた。
出てきたエラーの原因
これはdocusaurusがというよりか、Node.js使っていると発生するエラーで、監視対象のファイル数上限に達した場合に出力されるらしい。
参考: エラー System limit for number of file watchers reachedの対応 | Honmushi blog
で、上記のサイトにそのまま対策も上記サイトに書かれていたのでやってみた。
やってみる
まずは現状の値を確認する。
cat /proc/sys/fs/inotify/max_user_watches
8192なので上限値を一時的にあげてみる。
sudo sysctl fs.inotify.max_user_watches=24288
もう一度値を調べてみると、反映されていることを確認しました。
これだとOSを再起動したら戻ってしまうので、戻らないようにするには恒久対策をしてください。
改めてyarn start
では改めて実施。
vagrant@development-server:~/tmp/20201121/my-website$ yarn start yarn run v1.22.4 $ docusaurus start Starting the development server... Docusaurus website is running at: http://localhost:3000/ ✔ Client Compiled successfully in 7.60s ℹ 「wds」: Project is running at http://localhost:3000/ ℹ 「wds」: webpack output is served from / ℹ 「wds」: Content not from webpack is served from /home/vagrant/tmp/20201121/my-website ℹ 「wds」: 404s will fallback to /index.html
ふむ。エラー出力されずに正常に動いた。
Node.jsはバサッとやってくれるのはいいけどリソースがっつり使っちゃうからそこはどうなのかと思いつつもめちゃ便利だからやめられない。
それではー。