Maaz Zindani

Loading the index…

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

npm cannot find the package version you asked for

Errornpm ERR! code ETARGET

Short answer

ETARGET means no published version satisfies the exact version, range or tag you gave. List what the registry holds with npm view, then use a version that exists. Also check for a before date limit in your npm config, a custom registry, and a package.json range that points at an unpublished release.

  • Applies to npm 10, Node.js 22, Ubuntu 24.04, macOS 15
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Ask the registry which versions exist for the package, using the name from the error.

    npm view PACKAGE versions
  2. 2Match what you see, then jump to its fix

    1. 1No matching version found for PACKAGE@1.2.3The version or range in package.json was never publishedFix
    2. 2No matching version found for PACKAGE@... with a date before ...The before option limits installs to an older dateFix
    3. 3ETARGET for a package that exists on npmjs.com, only on one machine or in CInpm is asking a different registry that lacks the packageFix

What does the error look like?

  • npm ERR! code ETARGET
  • npm ERR! notarget No matching version found for

Cause 1 of 3

The version or range in package.json was never published

1Check

An exact version fails if it was not published, and so does a range with no match. Compare it with the real list, and check dist-tags such as latest.

npm view PACKAGE versions
npm dist-tag ls PACKAGE

2Fix

Change the entry to a version that exists, or use a range that matches one.

npm install PACKAGE@latest
# or a quoted range
npm install "PACKAGE@>=1.2.0 <2"

3Verify

The install completes and the version is the one you expect.

npm ls PACKAGE

Confirmed by docs.npmjs.com

Did this fix it?

Cause 2 of 3

The before option limits installs to an older date

1Check

When the before option is set, npm only considers versions published on or before that date, and the install fails if no version qualifies. It may sit in .npmrc or an environment variable.

npm config get before
npm config ls -l | grep -i before

2Fix

Remove the setting, or move the date later than the release you need.

npm config delete before

3Verify

npm config get before prints null, and the install works.

npm config get before
npm install

Confirmed by docs.npmjs.com

Did this fix it?

Cause 3 of 3

npm is asking a different registry that lacks the package

1Check

The registry setting defaults to https://registry.npmjs.org/. A private or mirror registry that does not hold the version returns no match.

npm config get registry
npm view PACKAGE versions --registry https://registry.npmjs.org/

2Fix

Point npm at the registry that holds the version, or ask the owner of the mirror to add it.

npm config set registry https://registry.npmjs.org/

3Verify

npm view now lists the version you need.

npm view PACKAGE versions

Confirmed by docs.npmjs.com

Did this fix it?

How do I stop it coming back?

  • Copy versions from npm view output, not from memory or a README.
  • Use ranges such as ^1.2.0 in package.json and commit the lockfile.
  • Keep registry and before settings in the project .npmrc so every machine gets the same ones.

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

Next step

Want this handled for good?

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