How to fix npm ERR! code ENOENT npm ERR! ENOENT: no such file or directory, open '/home/user/.npm/_cacache' in npm

npmBEGINNERMEDIUMUpdated Dec 5, 2025ยท 141 views

The _cacache directory, which npm uses to store downloaded packages and metadata, is missing or inaccessible. This error occurs when npm cannot find or write to its internal cache directory.

Quick fix

Fixes npm ERR! code ENOENT npm ERR! ENOENT: no such file or directory, open '/home/user/.npm/_cacache'

npm config get cache
  1. Check npm cache location
  2. Clear and rebuild the npm cache
  3. Fix permission issues (macOS/Linux)
  4. Verify npm installation
npm โ€” error
npm config get cache
npm ERR! code ENOENT
npm ERR! ENOENT: no such file or directory, open '/home/user/.npm/_cacache'

What this error means

The _cacache directory, which npm uses to store downloaded packages and metadata, is missing or inaccessible. This error occurs when npm cannot find or write to its internal cache directory. The _cacache folder is a content-addressable cache (using the cacache library) that stores all HTTP request data and package information. When npm cannot locate this directory or lacks permissions to access it, package installation fails with an ENOENT (Error NO ENTry) error. ENOENT specifically indicates npm can't access expected files within _cacache, typically due to: 1. The directory missing entirely 2. Permission restrictions preventing access 3. Incomplete cleanup from a previous npm operation

Typical symptoms

  • npm install fails with 'ENOENT: no such file or directory ~/.npm/_cacache'
  • npm ERR! code ENOENT appears in terminal output
  • Package installation hangs or times out during dependency resolution
  • Error message includes path to _cacache directory
  • npm functions normally but certain packages fail to cache

Common causes

  1. Cache directory was deleted or corrupted but npm expects it to exist
  2. Permission denied - files in ~/.npm are owned by root (from using sudo npm)
  3. npm was installed globally with sudo but run locally without sudo
  4. Incomplete npm upgrade left cache in inconsistent state
  5. Antivirus or security software deleted cache files as suspicious
  6. File system issue or disk space exhaustion caused cache corruption

How to fix "npm ERR! code ENOENT npm ERR! ENOENT: no such file or directory, open '/home/user/.npm/_cacache'"

1Check npm cache location

First, verify where npm expects the cache to be:

bash
npm config get cache

On Windows, this typically shows %LocalAppData%\npm-cache.
On macOS/Linux, this shows ~/.npm.

2Clear and rebuild the npm cache

Run the cache clean command with the force flag:

bash
npm cache clean --force

This deletes the entire cache directory and removes corrupted files. npm will automatically recreate the _cacache directory on the next install.

3Fix permission issues (macOS/Linux)

If you previously used sudo npm install, the ~/.npm directory may be owned by root:

bash
sudo chown -R $(whoami) ~/.npm

This ensures your user account owns the cache directory.

4Verify npm installation

Verify the cache is functioning properly:

bash
npm cache verify

This garbage collects unneeded data and verifies the integrity of the cache index. It will confirm that _cacache and related directories are present and accessible.

5Delete node_modules and reinstall

If the issue persists, perform a complete clean install:

bash
rm -rf node_modules package-lock.json
npm cache clean --force
npm install

This removes all cached packages and local dependencies, forcing npm to rebuild everything from scratch.

6Change cache location (if problems persist)

If you continue experiencing permission issues, configure npm to use a different cache directory:

bash
npm config set cache ~/.npm-global

Verify the configuration:

bash
npm config get cache

This avoids permission conflicts with system directories.

Advanced notes

Cache locations by OS:
- macOS/Linux: ~/.npm/_cacache
- Windows: %LocalAppData%\npm-cache\_cacache

Avoid sudo npm: Using sudo npm install creates root-owned files in ~/.npm that your user account cannot modify later. Use a Node version manager like nvm to install Node.js without requiring sudo.

Self-healing cache: npm v5+ cache is designed to recover automatically from minor corruption. Use npm cache verify instead of npm cache clean when possible.

Antivirus interference: On some systems (particularly Windows), security software may delete cache files. Whitelist your npm cache directory if you see repeated failures.

Frequently asked questions

What does "npm ERR! code ENOENT npm ERR! ENOENT: no such file or directory, open" mean?
The _cacache directory, which npm uses to store downloaded packages and metadata, is missing or inaccessible. This error occurs when npm cannot find or write to its internal cache directory. The _cacache folder is a content-addressable cache (using the cacache library) that stores all HTTP request data and package information.
How do I fix "npm ERR! code ENOENT npm ERR! ENOENT: no such file or directory, open"?
The _cacache directory, which npm uses to store downloaded packages and metadata, is missing or inaccessible. This error occurs when npm cannot find or write to its internal cache directory.
What causes "npm ERR! code ENOENT npm ERR! ENOENT: no such file or directory, open"?
Cache directory was deleted or corrupted but npm expects it to exist Permission denied - files in ~/.npm are owned by root (from using sudo npm) npm was installed globally with sudo but run locally without sudo
Is the "npm ERR! code ENOENT npm ERR! ENOENT: no such file or directory, open" error serious?
It is a medium-severity error โ€” more of a blocker than a risk. The steps above resolve it.

Official resources & further reading