Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Node.js, PHP and APIs

npm install fails with 404 Not Found for a package that exists

Errornpm ERR! Error: 404 Not Found

Short answer

A 404 from npm means the registry that npm asked has no such package for you. Check which registry the package's scope is mapped to, because a scope can point at a private registry. Scoped packages are private by default, so a missing login or access gives 404 too. Retry later if the registry had a glitch.

  • Applies to npm 10, npm 11, Node.js 22
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Print every npm setting that applies, including .npmrc files in the project and in your home folder. Look for the registry line and for any line that starts with the package scope.

    npm config ls -l
  2. 2Match what you see, then jump to its fix

    1. 1The 404 URL has a host that is not registry.npmjs.org, or a scoped package fails while unscoped ones installThe scope is mapped to a different registryFix
    2. 2The package is scoped (@myorg/name) and you published it yourself or got it from a teamA scoped package is private and you are not signed inFix
    3. 3The same install worked an hour ago and fails for a package you did not changeA short registry problemFix

What does the error look like?

  • npm ERR! Error: 404 Not Found

Cause 1 of 3

The scope is mapped to a different registry

1Check

A scope can be mapped to a registry, and installs for that scope then go to that registry. The default registry is https://registry.npmjs.org/. A stale mapping in a project or user .npmrc sends the request to a server that does not host the package.

npm config ls -l | grep -i registry
cat .npmrc ~/.npmrc

2Fix

Point the scope at the registry that really hosts the package, or remove the mapping to use the default registry.

npm config set @myorg:registry=https://registry.npmjs.org/

3Verify

Run the install again.

npm install @myorg/mypackage

Confirmed by docs.npmjs.com

Did this fix it?

Cause 2 of 3

A scoped package is private and you are not signed in

1Check

Scoped packages are private by default, and the first public publish needs an access flag. Check how the package was published and whether you are logged in to the registry that holds it.

npm config ls -l | grep -i registry

2Fix

Log in with an account that has access. If the package should be public, the owner publishes it with the public access flag.

npm login
# owner, for a public scoped package:
npm publish --access public

3Verify

Install the package again.

npm install @myorg/mypackage

Confirmed by docs.npmjs.com

Did this fix it?

Cause 3 of 3

A short registry problem

1Check

The npm documentation calls a one-off 404 most likely a temporary registry glitch. Check the registry status page before changing your setup.

npm install

2Fix

Wait a short while and run the install again. If it keeps failing for one package version, ask the package owner to publish a fixed version.

npm install

3Verify

The install finishes without a 404.

npm ls --depth=0

Confirmed by docs.npmjs.com

Did this fix it?

How do I stop it coming back?

  • Commit a project .npmrc that maps each private scope to its registry, and keep tokens out of it.
  • Review ~/.npmrc when a laptop or CI image is reused for another client or team.
  • Use npm login on CI through the registry's own token mechanism, never through a pasted password.
  • Install from a lock file so one outage does not change which versions you resolve.

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

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 fix

Back 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

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.