npm tried to rename a staging folder that had already been removed (cleanup, AV, or race). Clean node_modules/cache, stop concurrent installs, and reinstall once.
npm writes temp content under node_modules/.staging and then renames it into place. If another process deletes .staging (cleanup script, AV, concurrent npm), the rename target disappears and npm throws ENOENT. It also occurs when node_modules is mounted from an empty host volume, or when previous failed installs left partial folders that get removed mid-run. Running multiple npm installs in parallel is a common trigger.
Ensure only one npm/yarn/pnpm process runs in the project. Stop scripts that auto-clean node_modules.
rm -rf node_modules package-lock.json
npm cache clean --forceAdd a Defender/AV exclusion for the project during installation so .staging is not removed mid-run.
In Docker/CI, do not mount an empty host node_modules over the container path. Build dependencies inside the image or mount only source.
npm is not safe to run in parallel on the same tree; run installs sequentially. In CI, avoid cleaning node_modules mid-install (e.g., concurrent cache warmers). If you need per-step isolation, install in a fresh workspace each time. Docker Compose users should mount only source and keep node_modules inside the image or a dedicated volume to prevent disappearing .staging directories.
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 ci