Node.js: what is ENOSPC error and how to solve?

后端 未结 16 2524
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-11-22 08:52

I have a problem with Node.js and uploading files to server. For uploading files to server I use this plugin. When starting file upload to the server, Node.js process crashe

16条回答
  •  一向
    一向 (楼主)
    2020-11-22 09:34

    On Linux, this is likely to be a limit on the number of file watches.

    The development server uses inotify to implement hot-reloading. The inotify API allows the development server to watch files and be notified when they change.

    The default inotify file watch limit varies from distribution to distribution (8192 on Fedora). The needs of the development server often exceeds this limit.

    The best approach is to try increasing the file watch limit temporarily, then making that a permanent configuration change if you're happy with it. Note, though, that this changes your entire system's configuration, not just node.

    To view your current limit:

    sysctl fs.inotify.max_user_watches
    

    To temporarily set a new limit:

    # this limit will revert after reset
    sudo sysctl fs.inotify.max_user_watches=524288
    sudo sysctl -p
    # now restart the server and see if it works
    

    To set a permanent limit:

    echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf
    sudo sysctl -p
    

提交回复
热议问题