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 notice access token expired or revoked. Please try logging in again.
Token has expired - npm authentication failure
npm ERR! code EAI_AGAIN
How to fix "EAI_AGAIN" in npm
npm error code E403 npm error 403 Forbidden - PUT https://registry.npmjs.org/<package>
How to fix 'E403 Forbidden' error in npm
npm ERR! code EUSAGE npm ERR! Usage error
How to fix "npm ERR! code EUSAGE" in Node.js projects
npm ERR! code E401 npm ERR! 401 Unauthorized
How to fix "E401 Unauthorized" in npm