npm is broken and will not update itself: reinstall it the supported way
npm does not support Node.js v<version>Short answer
A broken npm cannot always repair itself, so replace the whole Node.js install instead of patching it. Install nvm, install an LTS Node version (npm comes with it), run nvm install-latest-npm if you need the newest npm for that Node, and verify the cache with npm cache verify. The npm docs recommend a version manager over a plain installer.
Fix it fast
1Find out which cause you have
See what is installed and where the shell finds it, before you remove anything.
which node npm node -v npm -v2Match what you see, then jump to its fix
- 1
npm prints that it does not support your Node.js version, or fails right after a Node upgrade.npm and Node.js versions do not matchFix - 2
npm install -g npm@latest fails because npm itself cannot run, or global installs fail on permissions.Node.js was installed with a plain installer and npm is damagedFix - 3
npm runs, but installs fail with strange integrity or fetch errors, or your npm is behind Node's bundled one.npm works but the cache or npm version is the problemFix
- 1
What does the error look like?
npm does not support Node.js v<version>EACCES
Cause 1 of 3
npm and Node.js versions do not match
1Check
nvm's README describes this exact case: npm is not upgraded automatically when you reinstall packages, so it can end up broken for the new Node.
nvm ls2Fix
Go back to a Node version that worked, delete the broken one, and install again with --latest-npm so npm is updated at the same time.
nvm use <last-working-version>
nvm uninstall <broken-version>
nvm install --latest-npm 'lts/*'3Verify
node and npm both print versions.
node -v && npm -vConfirmed by raw.githubusercontent.com
Cause 2 of 3
Node.js was installed with a plain installer and npm is damaged
1Check
The npm docs recommend a Node version manager and advise against a Node installer, because the installer puts npm in a directory with local permissions and can cause permission errors when you run npm packages globally.
which node2Fix
Install a version manager such as nvm, then install Node.js through it. The npm docs say you do not need to remove the current Node.js or npm first.
nvm install 22
nvm use 223Verify
which node now points inside the nvm folder.
which node npmConfirmed by docs.npmjs.com
Cause 3 of 3
npm works but the cache or npm version is the problem
1Check
npm cache verify garbage-collects unneeded data and checks the integrity of the cache index and cached data. The docs add that clearing the cache is rarely needed because it is self-healing.
npm cache verify2Fix
Verify the cache, then upgrade npm itself to the latest release.
npm cache verify
npm install -g npm@latest3Verify
Re-run the install that failed.
npm -v && npm installConfirmed by docs.npmjs.com
How do I stop it coming back?
- Manage Node.js with nvm or another version manager instead of a system installer.
- After changing Node versions, run nvm install-latest-npm.
- Do not delete files inside the npm folder by hand.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
Related fixes
Back end
Create React App says Node is too old, and npm will not run on the new one
npm does not support Node.js v10.19.0
The shell is running an old Node.js that is below the version Create React App needs.
3 causes, each with a fixBack end
npm install worked but the command is not found
bash: vite: command not found
npm puts a local install's command in the project's node_modules/.bin, which is not on your shell PATH, so run it with npx or from an npm script.
3 causes, each with a fixBack end
ng serve says it cannot determine the project or target
Cannot determine project for command.
The Angular CLI looked through angular.json for a project that defines the target you asked for (serve, build, test) and found none, or found several and could not pick one.
3 causes, each with a fixBack end
ng fails with Cannot find module @angular/cli/bin/ng
Cannot find module '@angular/cli/bin/ng'
The ng command is the entry point to the Angular CLI package.
2 causes, each with a fixBack end
Angular app shows 'Cannot GET /' when served by a Node.js server
Cannot GET /dashboard
Cannot GET / is Express saying no route or file matches the request.
3 causes, each with a fixBack end
ng serve cannot find the dev-server builder package
Could not find the implementation for builder @angular/build:dev-server
The builder named in angular.json (for example @angular-devkit/build-angular:dev-server) is looked up as an npm package starting from the workspace root.
3 causes, each with a fix