How to fix npm ERR! code ENOTARGET in npm
The ENOTARGET error occurs when npm cannot find a version of a package matching your requirements. This usually means the version doesn't exist or has been unpublished.
Quick fix
Fixes npm ERR! code ENOTARGET
npm view package-name versions
# See dist-tags
npm view package-name dist-tags- Check available versions
- Verify version specification
- Use a valid version
- Fix version range
npm view package-name versions# See dist-tagsnpm view package-name dist-tagsnpm ERR! code ENOTARGET
What this error means
ENOTARGET means npm searched the registry for a package version matching your specification but found nothing. This can happen with exact versions that don't exist, ranges that exclude all published versions, or packages that have been unpublished. Remember that npm packages can be unpublished within 24 hours of publishing (or 72 hours if no dependents). After that, they're permanent.
Typical symptoms
- npm install fails with "no matching version"
- Exact version specified doesn't exist
- Version range matches nothing
- Package was recently unpublished
- Private package not accessible
- Typo in version specification
Common causes
- Version number typo
- Version was unpublished
- Version doesn't exist yet
- Version range too narrow
- Prerelease tag mismatch
- Package name typo
- Registry sync delay
How to fix "npm ERR! code ENOTARGET"
List all published versions:
npm view package-name versions
# See dist-tags
npm view package-name dist-tagsCheck your package.json:
# See what you're requesting
npm pkg get dependencies.package-name
# Compare with available
npm view package-name versionUpdate to an existing version:
# Install latest
npm install package-name@latest
# Or specific existing version
npm install package-name@1.2.3Adjust your range:
// Maybe too specific
"dep": "1.2.3" // Exact version
// More flexible
"dep": "^1.2.0" // Compatible versions
"dep": ">=1.0.0" // MinimumPrerelease needs explicit tag:
# See all versions including prereleases
npm view package-name versions --json
# Install prerelease explicitly
npm install package-name@next
npm install package-name@2.0.0-beta.1Ensure correct registry:
# Check current registry
npm config get registry
# Reset to default
npm config set registry https://registry.npmjs.orgAdvanced notes
Unpublished packages leave a gap - the version number cannot be reused. For critical dependencies, consider vendoring or using a private registry mirror. Use package-lock.json to ensure version consistency. If a package disappears, check for forks or alternatives. The npm registry API shows detailed package metadata.
Frequently asked questions
- What does "npm ERR! code ENOTARGET" mean?
- ENOTARGET means npm searched the registry for a package version matching your specification but found nothing. This can happen with exact versions that don't exist, ranges that exclude all published versions, or packages that have been unpublished. Remember that npm packages can be unpublished within 24 hours of publishing (or 72 hours if no dependents).
- How do I fix "npm ERR! code ENOTARGET"?
- The ENOTARGET error occurs when npm cannot find a version of a package matching your requirements. This usually means the version doesn't exist or has been unpublished.
- What causes "npm ERR! code ENOTARGET"?
- Version number typo Version was unpublished Version doesn't exist yet
- Is the "npm ERR! code ENOTARGET" error serious?
- It is a medium-severity error โ more of a blocker than a risk. The steps above resolve it.
Official resources & further reading
- ๐npm Official Documentation
- ๐
- ๐