How to fix npm ERR! Error: EACCES: permission denied, open '<path>' in npm

npmBEGINNERMEDIUMUpdated Dec 2, 2025· 228 views

npm tried to read or write a file it cannot access (package-lock, cache tarball, or global path). Fix ownership/locks on that path or move npm to user-owned locations before retrying.

Quick fix

Fixes npm ERR! Error: EACCES: permission denied, open '<path>'

# copy the path from the error
stat <path>
ls -l <path>
  1. Inspect the failing path
  2. Fix ownership where you own the files
  3. Move cache and prefix to your home directory
  4. Release locks from AV/IDEs
npm — error
# copy the path from the error
stat <path>
ls -l <path>
npm ERR! Error: EACCES: permission denied, open '<path>'

What this error means

The fs.open call failed because the target file is not readable/writable by the current user. npm often hits this when opening package-lock.json, cache tarballs, or global install paths that are root-owned, read-only, or locked by another process. This happens after mixing sudo and non-sudo installs, cloning into directories with restrictive ACLs, running on WSL2/SMB mounts with Windows permissions, or when antivirus/IDE file watchers hold handles in node_modules. Docker/CI jobs that run as non-root against root-owned volumes see the same EACCES on open.

Typical symptoms

  • npm install/ci fails with EACCES: permission denied, open '<path>'
  • Works with sudo/Admin but fails as the normal user
  • package-lock.json or cache tarballs fail to open
  • npm cache verify reports permission errors
  • On Windows/WSL, errors mention file-in-use or Windows paths
  • In Docker/CI, the failing path is on a bind-mounted volume

Common causes

  1. Root-owned files from prior sudo installs (global or local)
  2. Workspace mounted read-only or with mismatched ACLs (WSL2/SMB/AFS)
  3. Antivirus/Defender or IDE (VS Code) locking package files
  4. npm cache owned by a different user or corrupted permissions
  5. Corporate images restricting /usr/local or /opt/homebrew
  6. File ownership drift after git checkouts with restrictive umask

How to fix "npm ERR! Error: EACCES: permission denied, open '<path>'"

1Inspect the failing path
bash
# copy the path from the error
stat <path>
ls -l <path>
2Fix ownership where you own the files
bash
sudo chown -R $(whoami) .
# for global prefix you administer
sudo chown -R $(whoami) $(npm config get prefix)/{lib/node_modules,bin,share}
3Move cache and prefix to your home directory
bash
npm config set cache ~/.npm-cache
mkdir -p ~/.npm-global
npm config set prefix ~/.npm-global
export PATH="$HOME/.npm-global/bin:$PATH"
4Release locks from AV/IDEs

Close VS Code/terminals holding node_modules, and add a Windows Defender/EDR exclusion for your project and npm cache so files can be opened.

5Reset a bad cache
bash
npm cache clean --force
npm cache verify
6Re-run install as the correct user
bash
npm ci
# or
npm install

Run inside the workspace you own; avoid sudo unless intentionally installing system-wide.

Advanced notes

WSL2 on /mnt/c uses NTFS ACLs that often block POSIX writes; clone to the Linux filesystem (e.g., ~/projects) to avoid EACCES on open. Docker bind mounts inherit host ownership—run the container with matching UID/GID or chown the workspace volume before npm install. On macOS with Homebrew, /opt/homebrew may be admin-only; using nvm/fnm keeps npm files in $HOME and sidesteps system ACLs.

Frequently asked questions

What does "npm ERR! Error: EACCES: permission denied, open '<path>'" mean?
open call failed because the target file is not readable/writable by the current user. json, cache tarballs, or global install paths that are root-owned, read-only, or locked by another process. This happens after mixing sudo and non-sudo installs, cloning into directories with restrictive ACLs, running on WSL2/SMB mounts with Windows permissions, or when antivirus/IDE file watchers hold handles in node_modules.
How do I fix "npm ERR! Error: EACCES: permission denied, open '<path>'"?
npm tried to read or write a file it cannot access (package-lock, cache tarball, or global path). Fix ownership/locks on that path or move npm to user-owned locations before retrying.
What causes "npm ERR! Error: EACCES: permission denied, open '<path>'"?
Root-owned files from prior sudo installs (global or local) Workspace mounted read-only or with mismatched ACLs (WSL2/SMB/AFS) Antivirus/Defender or IDE (VS Code) locking package files
Is the "npm ERR! Error: EACCES: permission denied, open '<path>'" error serious?
It is a medium-severity error — more of a blocker than a risk. The steps above resolve it.

Official resources & further reading