npm cannot find the package version you asked for
npm ERR! code ETARGETShort 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.
Fix it fast
1Find out which cause you have
Ask the registry which versions exist for the package, using the name from the error.
npm view PACKAGE versions2Match what you see, then jump to its fix
- 1
No matching version found for PACKAGE@1.2.3The version or range in package.json was never publishedFix - 2
No matching version found for PACKAGE@... with a date before ...The before option limits installs to an older dateFix - 3
ETARGET for a package that exists on npmjs.com, only on one machine or in CInpm is asking a different registry that lacks the packageFix
- 1
What does the error look like?
npm ERR! code ETARGETnpm 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 PACKAGE2Fix
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 PACKAGEConfirmed by docs.npmjs.com
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 before2Fix
Remove the setting, or move the date later than the release you need.
npm config delete before3Verify
npm config get before prints null, and the install works.
npm config get before
npm installConfirmed by docs.npmjs.com
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 versionsConfirmed by docs.npmjs.com
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
Back end
npm install refuses with ERESOLVE and a peer dependency conflict
npm error ERESOLVE unable to resolve dependency tree
ERESOLVE means two packages in your tree ask for incompatible versions of a shared peer dependency, and npm 7 or newer refuses to guess.
3 causes, each with a fixBack end
Application Load Balancer returns 502 for a Node.js target
HTTPCode_ELB_502_Count
An ALB returns 502 when the target gives it something it cannot use: a refused or reset connection, a connection closed mid-request, a bad response, or a header over 32 K.
4 causes, each with a fixBack end
corepack enable fails: permission denied while creating the pnpm link
Internal Error: EACCES: permission denied, symlink '../lib/node_modules/corepack/dist/pnpm.js' -> '/usr/local/bin/pnpm'
corepack enable writes small link files for yarn and pnpm next to your node binary.
2 causes, each with a fixBack 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
firebase deploy cannot load your functions: user code failed to load
Functions codebase could not be analyzed successfully. It may have a syntax or runtime error
The Firebase CLI loads your functions code on your machine before it deploys, to learn which functions exist.
4 causes, each with a fixBack end
firebase deploy stops because the predeploy lint step failed
Error: There was an error deploying functions
The predeploy hook in firebase.json runs npm run lint before every deploy, and a failing hook cancels the deploy.
3 causes, each with a fix