This will probably fix your problem if you're struggling to deploy a React solution that was created with the Visual Studio template (and has a web.config). In Azure Release Pipelines, when selecting the template, use:
Azure App Service deployment
Instead of:
Deploy a Node.js app to Azure App Service
It worked for me!
There's another possibility that hasn't been considered or discussed in any of the answers so far: symbolic link cycles.
Node's recursive filesystem watcher does not appear to detect and handle cycles of symlinks. So you can easily trigger this error with an arbitrarily high nfiles
ulimit by simply running:
mkdir amkdir a/bcd a/b ln -s .. c
GNU find
will notice the symlink cycle and abort:
$ find a -followaa/bfind: File system loop detected; āa/b/cā is part of the same file system loop as āaā.
but node won't. If you set up a watch on the tree, it'll spew a EMFILE, too many open files
error.
Amongst other things this can happen in node_modules
where there's a containment relationship:
parent/package.jsonchild/package.json
which is how I encountered it in a project I was trying to build.
Note that you don't necessarily need to overcomplicate this issue, trying again works just fine.
import { promises as fs } from "fs";const filepaths = [];const errors = [];function process_file(content: string) {// logic here}await Promise.all(filepaths.map(function read_each(filepath) {return fs.readFile(filepath, "utf8").then(process_file).catch(function (error) {if (error.code === "EMFILE") return read_each(filepath);else errors.push({ file: filepath, error });});}),);
What you did is almost right:
sysctl -w kern.maxfiles=20480
On my macOS, the default is 491520 where what you were setting is actually lower value than of my system default, I just set it to 999999 and it worked perfectly. No more of that error.
Edit: I forgot to mention to restart afterwards.
Hope this helps.
I had this issue, and i solved it by running npm update
and it worked.
In some cases you may need to remove node_modules rm -rf node_modules/
On Windows, there is seems that no the ulimit
command to increase the number of open files. In graceful-fs
, it maintains a queue to run I/O operations, eg: read/write file.
However, fs.readFile, fs.writeFile
are based on fs.open
, so you will need open/close files manually to solve this error.
import fs from 'fs/promises';const fd = await fs.open('path-to-file', 'r');await fd.readFile('utf-8'); // <== read through file handleawait fd.close(); // <== manually close it
This may happen after changing the Node versionERR emfile too many open files
It should be absolutely fixed the issue
first update your version of expo using expo update
and then run yarn / npm install
. This solved the issue for me!