Windows/WSL often throws EPERM when npm touches files locked by AV/IDEs or on restricted mounts. Release locks, fix ownership, shorten paths, and re-run npm with user-owned locations.
EPERM indicates the OS blocked the requested filesystem operation even before checking permissions. In npm this happens when Windows/WSL or security tools deny rename/unlink/mkdir on node_modules, or when the path lives on a restricted mount or long path. It is common on Windows with Defender/AV, long paths, or VS Code holding handles; on WSL2 working on /mnt/c (NTFS); and in Docker/CI when the workspace is owned by a different user. Unlike EACCES, EPERM often points to policy or a lock rather than simple UNIX mode bits.
Copy the path from the error. On Windows, use Resource Monitor or handle.exe <path> to see which process holds it.
Close VS Code/terminals watching the repo. Add Defender/AV exclusions for the project and npm cache. Retry from a fresh shell.
On WSL, clone to ~/projects (ext4) instead of /mnt/c. Shorten Windows paths to avoid MAX_PATH issues.
npm config set cache ~/.npm-cache
mkdir -p ~/.npm-global
npm config set prefix ~/.npm-global
export PATH="$HOME/.npm-global/bin:$PATH"
rm -rf node_modules package-lock.json
npm cache clean --forcenpm ciRun containers with matching UID/GID or chown the workspace volume before npm install so the OS does not reject operations.
EPERM on Windows often disappears when Developer Mode is enabled (symlink/rename policies are relaxed) and Defender exclusions are set. In CI, artifacts copied from root-owned build steps can cause EPERM in later non-root stepsโclean and chown the workspace between steps. If a corporate policy forces read-only attributes, install dependencies in a per-user cache/prefix outside the locked directory.
npm 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