Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Watchpack Error (watcher): Error: EMFILE: too many open files, watch '/'

Without making any changes on the webpack config, webpack wants to watch all parent directories, up to the root directory.

So it causes the error: EMFILE: too many open files, watch '/'

Did anybody have the same problem, or does anbody have an idea how I can find the reason or does anybody know a solution?

The Webpack config is:

const path = require('path');

module.exports = {
    entry: './src/index.js',
    watch: true,
    watchOptions: {
        ignored: '/node_modules/',
    },
    output: {
        path: path.resolve(__dirname, 'dist'),
    },
    module: {
        rules: [
            {
                test: /\.js$/,
                exclude: '/node_modules/',
                use: {
                    loader: 'babel-loader',
                    options: {
                        presets: ['@babel/preset-env'],
                    },
                },
            },
            {
                test: /\.less$/i,
                use: [
                  // compiles Less to CSS
                  'style-loader',
                  'css-loader',
                  'less-loader',
                ]
            }
        ],
    }
}
like image 971
Artisan72 Avatar asked Nov 26 '25 06:11

Artisan72


2 Answers

I faced them same issue, multiple times. Reboot works but is tedious. This post here points so another solution.

Checking cat /proc/sys/fs/inotify/max_user_instances (mine was 128) and increase the value.

Can be done with:

sudo sysctl fs.inotify.max_user_instances=256

This worked instantly.

Too survive a reboot the value must go to

/etc/sysctl.conf

see https://www.suse.com/support/kb/doc/?id=000020048

like image 61
Hank Lapidez Avatar answered Nov 27 '25 21:11

Hank Lapidez


It's been a system problem. After rebooting, it worked again as usual.

like image 21
Artisan72 Avatar answered Nov 27 '25 21:11

Artisan72



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!