webpack --watch exits after building once

后端 未结 2 1140
情书的邮戳
情书的邮戳 2020-12-16 06:16

I was using webpack --watch statement to run my webpack in watch mode for building my ReactJS app. However for some reason, it stopped working now. It now just

相关标签:
2条回答
  • 2020-12-16 06:34

    The problem seems to have arose because of the inotify watch limit

    Listen uses inotify by default on Linux to monitor directories for changes. It's not uncommon to encounter a system limit on the number of files you can monitor.

    The current watch limit can be seen through the command

    $ cat /proc/sys/fs/inotify/max_user_watches
    

    In my case it was 8192 which is the default value for linux X64 systems

    To change it temporarily we need to run the following commands

    $ sudo sysctl fs.inotify.max_user_watches=524288
    $ sudo sysctl -p
    

    For permanently setting it we should run run

    $ echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf
    $ sudo sysctl -p
    
    0 讨论(0)
  • 2020-12-16 06:48

    This happen mostly because it watches the node_modules folder and exceeds the limit. In this case, rather than modifying the host system, use:

      watchOptions: {
        aggregateTimeout: 300,
        poll: 1000,
        ignored: /node_modules/
      }
    

    to the webpack.config.js exports.

    0 讨论(0)
提交回复
热议问题