npm cannot list a directory (node_modules/cache/global path) because it is unreadable or locked. Fix ownership/ACLs, move npm to user-owned dirs, and release AV/IDE locks.
npm calls scandir to enumerate directories while resolving dependencies, reading cache entries, and linking global binaries. If the target directory is unreadable, root-owned, on a read-only mount, or held by another process, scandir throws EACCES and npm aborts. This occurs after sudo installs leave root-owned folders, when node_modules lives on NTFS/SMB with restrictive ACLs (WSL2, network shares), or when antivirus/EDR/IDEs block directory reads. CI/Docker runs as non-root against root-owned workspaces show the same failure.
ls -ld <path>
stat <path>sudo chown -R $(whoami) .
chmod -R u+rw node_modulesnpm config set cache ~/.npm-cache
mkdir -p ~/.npm-global
npm config set prefix ~/.npm-global
export PATH="$HOME/.npm-global/bin:$PATH"Add Defender/AV exclusions for the project and npm cache; close VS Code/terminals holding node_modules so scandir can read the directory.
On WSL, clone to ~/projects (ext4) instead of /mnt/c. In Docker, run with matching UID/GID or chown the bind-mounted workspace.
npm cache clean --force
npm cici recreates node_modules and ensures directory permissions are consistent.
Network/SMB shares can deny Unix read bits even when Windows shows access; cloning locally avoids scandir EACCES. Corporate macOS images may require admin to read /usr/local/lib/node_modulesโkeep globals in $HOME via nvm/fnm. In CI, permissions may drift if earlier steps ran as root; chown the workspace before installing to avoid unreadable cache directories.
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