How to fix npm ERR! code ENOTARGET in npm

npmBEGINNERMEDIUMUpdated Dec 6, 2025ยท 481 views

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
  1. Check available versions
  2. Verify version specification
  3. Use a valid version
  4. Fix version range
npm โ€” error
npm view package-name versions
# See dist-tags
npm view package-name dist-tags
npm 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

  1. Version number typo
  2. Version was unpublished
  3. Version doesn't exist yet
  4. Version range too narrow
  5. Prerelease tag mismatch
  6. Package name typo
  7. Registry sync delay

How to fix "npm ERR! code ENOTARGET"

1Check available versions

List all published versions:

bash
npm view package-name versions

# See dist-tags
npm view package-name dist-tags
2Verify version specification

Check your package.json:

bash
# See what you're requesting
npm pkg get dependencies.package-name

# Compare with available
npm view package-name version
3Use a valid version

Update to an existing version:

bash
# Install latest
npm install package-name@latest

# Or specific existing version
npm install package-name@1.2.3
4Fix version range

Adjust your range:

json
// Maybe too specific
"dep": "1.2.3"  // Exact version

// More flexible
"dep": "^1.2.0"  // Compatible versions
"dep": ">=1.0.0"  // Minimum
5Check for prerelease versions

Prerelease needs explicit tag:

bash
# 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.1
6Check registry configuration

Ensure correct registry:

bash
# Check current registry
npm config get registry

# Reset to default
npm config set registry https://registry.npmjs.org

Advanced 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