Error Knowledge Base NPM ENFILE

npm ERR! code ENFILE

The system hit the global open file limit (ENFILE).

Affected versions: All supported npm versions.

What This Error Means

The system hit the global open file limit (ENFILE).

How to Fix It

  1. Identify the path npm is failing on (look for the last referenced file path in the error output).
  2. Increase open file limits (ulimit -n) and retry. Also close background tools that watch many files.
  3. Retry after cleaning local state when safe (common: remove node_modules and retry install).

Why It Happens

  • The process (or system) hit open file limits while npm was reading/writing many files.

How to Verify

  1. Re-run the original command and confirm the filesystem error no longer appears.
  2. If this is a permission fix, confirm new files in node_modules are owned by the expected user.

Manual filesystem checks

  1. Check file descriptor limits: ulimit -n.

Common CLI Output

npm ERR! code ENFILE

Prevention Tips

  • Keep npm cache and project directories owned by the build user.
  • Avoid running project installs as root unless you know exactly why you need it.
  • Ensure CI runners have enough disk space and sensible file descriptor limits.

Where This Can Be Triggered

github.com/npm/cli/blob/417daa72b09c5129e7390cd12743ef31bf3ddb83/lib/commands/cache.js

This is a representative filesystem write path during npm operations. Filesystem codes like this are raised by Node/OS when this write fails. - GitHub

        break
      }
      output.standard(`Deleted: ${key}`)
      await cacache.rm.entry(cachePath, key)
      // XXX this could leave other entries without content!
      await cacache.rm.content(cachePath, entry.integrity)
    }

Need help or found a mistake? Contact RepoFlow support for questions.

Join our mailing list