npm cannot create a directory because the filesystem or policy blocks it (Windows/WSL AV locks, root-owned prefixes, read-only mounts). Use user-owned paths, release locks, and retry.
mkdir failed before permission checks completed, usually because Windows/WSL policy or locks blocked directory creation. npm hits this when writing to node_modules, cache, or global prefixes that are locked by AV, owned by another user, or on restricted mounts. It is frequent on Windows with Defender/EDR, WSL2 on /mnt/c, and Docker/CI when running as a different user than the volume owner. Root-owned remnants from earlier sudo installs can also cause mkdir to be rejected.
ls -ld <path> || true
stat $(dirname <path>)
df -h <path>Close VS Code/terminals, add Defender/AV exclusions for the project and npm cache, then retry.
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/.staging 2>/dev/null || trueOn WSL, move the repo to ext4 (~/projects). In Docker, run with matching UID/GID or chown the bind mount.
Corporate laptops sometimes apply AppLocker/Controlled Folder Access, blocking mkdir in developer directories; adding approved exclusions or using user-owned prefixes in $HOME avoids the policy. In CI, make sure the workspace isnβt mounted read-only and that earlier root steps didnβt leave .staging directories. For Windows long-path scenarios, enabling longPaths in git and npm can help but the primary fix is using a shorter, user-writable path.
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"
rm -rf node_modules package-lock.json
npm cache clean --force
npm ci