EACCES is the operating system’s “permission denied” code. npm reports it when it needs to create a folder, write a file or run a script somewhere your user account can’t write to. The path line in the error is the key: it tells you whether the problem is the global install folder, npm’s cache, or your project itself. Newer npm versions print the same thing as npm error code EACCES.
Causes
- A global install (
npm install -g) into a system folder such as/usr/local/lib/node_modulesor/usr/lib/node_modules, which belongs to root. - An earlier
sudo npm installthat left root-owned files in~/.npmor in the project’snode_modules. - Project files owned by another user, for example after uploading or copying them as a different account.
- Wrong file permissions, such as a folder without write permission for its owner.
- On shared hosting, trying to install into system folders, which no customer account can write to.
How to fix it
-
Read the
pathline and decide which of the cases below it matches. -
Global folder: don’t install globally. Run tools with
npx, or install them per project:npx some-cli --help npm install --save-dev some-cli -
If you really need global packages, move npm’s global prefix into your home folder:
mkdir -p ~/.npm-global npm config set prefix ~/.npm-global echo 'export PATH="$HOME/.npm-global/bin:$PATH"' >> ~/.bashrc source ~/.bashrcOn your own computer, a Node version manager such as nvm does the same thing automatically.
-
Cache owned by root (
~/.npm): on your own machine, run thechowncommand npm suggests in the error, then retry. -
Project folder: check ownership with
ls -la. Remove the broken install and reinstall as your normal user:rm -rf node_modules npm ciIf
rmitself is denied, the files belong to another user; fix ownership first (on your PC withsudo chown -R, on hosting ask support). -
Permissions: folders usually need
755and files644. The chmod calculator explains the numbers.
For permission errors outside npm, see permission denied writing files.
Prevention
- Never use
sudowith npm in a project folder. - Prefer project-local dev dependencies and
npxover global installs. - Upload project files as the same user that runs the app.
On ArabyHost
On ArabyHost AI/Developer plans, SSH runs inside a CloudLinux CageFS jail without root access, so system folders can’t be written and sudo isn’t available. That’s expected, not a fault: install packages locally in your project, use npx, or set the npm prefix to your home folder as shown above. For apps created in Setup Node.js App, enter the app’s environment with the command shown on its page (or use the Run NPM Install button), and npm installs into the app’s own environment with your user’s permissions. The SSH access guide covers connecting.
FAQ
Why shouldn't I use sudo npm install?
It runs package install scripts as root and leaves root-owned files in your project and cache, which causes the next EACCES. On shared hosting it isn't available anyway.
How do I run a CLI tool without installing it globally?
Use `npx tool-name`, or add it to the project with `npm install --save-dev tool-name` and call it from a script in `package.json`.
The error mentions ~/.npm/_cacache. What now?
Your cache contains files owned by another user, usually root after a sudo install. On your own machine, run the `chown` command npm prints in the error to give the folder back to your user.