The EACCES error occurs when npm cannot execute a binary due to insufficient permissions. This commonly happens after using sudo with npm or when file ownership is incorrect.
This error indicates npm tried to execute a binary file but lacks the necessary permissions. On Unix-like systems (Linux, macOS), files need the execute bit set and the user needs appropriate ownership/group membership to run them. The most common cause is using `sudo npm install` which creates files owned by root. When you later try to run npm commands as a regular user, you can't access or execute root-owned files. This can also occur when transferring node_modules between different operating systems (Windows to Linux) where Unix permissions aren't preserved.
Change ownership to your user:
# Fix project node_modules
sudo chown -R $(whoami) node_modules
# Fix global npm directories
sudo chown -R $(whoami) ~/.npm
sudo chown -R $(whoami) /usr/local/lib/node_modules
sudo chown -R $(whoami) /usr/local/binThen retry your npm command without sudo.
Clean reinstall often fixes permission issues:
rm -rf node_modules package-lock.json
npm installImportant: Do NOT use sudo for npm install.
Avoid system directories entirely:
mkdir -p ~/.npm-global
npm config set prefix ~/.npm-globalAdd to ~/.bashrc or ~/.zshrc:
export PATH=~/.npm-global/bin:$PATHReload shell and reinstall global packages.
Node Version Manager installs to your home directory, avoiding all permission issues:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash
source ~/.bashrc
nvm install 20
nvm use 20
# Now npm works without sudo
npm install -g some-packageIf files exist but lack execute bit:
# Make all .bin files executable
chmod +x node_modules/.bin/*
# Or for specific binary
chmod +x node_modules/.bin/webpackNever do this:
sudo npm install # Creates root-owned files
chmod 777 node_modules # Security vulnerabilityBest practices:
1. Use nvm to manage Node.js - avoids system directories
2. Never use sudo with npm
3. Configure npm prefix to user directory
4. Use npx for one-off commands instead of global installs
For Docker, run as non-root user:
RUN chown -R node:node /app
USER nodenpm ERR! code ENOAUDIT npm ERR! Audit endpoint not supported
How to fix "npm ERR! code ENOAUDIT - Audit endpoint not supported"
npm ERR! code EBADDEVENGINES npm ERR! devEngines.runtime incompatible with current node version
How to fix "npm ERR! code EBADDEVENGINES - devEngines.runtime incompatible with current node version"
npm ERR! code ETOOMANYARGS npm ERR! Too many arguments
How to fix "npm ERR! code ETOOMANYARGS - Too many arguments"
npm ERR! code EINVALIDTAGNAME npm ERR! Invalid tag name: tag names cannot contain spaces
How to fix "npm ERR! code EINVALIDTAGNAME - tag names cannot contain spaces"
npm ERR! code E400 npm ERR! 400 Bad Request
How to fix "npm ERR! code E400 - 400 Bad Request" error