npm "notarget No matching version found" - Fix Range That Cannot Resolve
A notarget error means npm walked the dependency graph and found a (often transitive) requirement whose range matches no published version. The constraint comes from inside your tree, not the top-level package you named.
What this error means
npm install fails with notarget No matching version found for <pkg>@<range>, where the package and range are ones you never wrote directly - they were introduced by a dependency of a dependency.
npm error code ETARGET
npm error notarget No matching version found for @acme/core@^5.0.0-next.12.
npm error notarget In most cases you or one of your dependencies are requesting
npm error notarget a package version that doesn't exist.Common causes
A transitive dependency pins a yanked or pre-release version
A nested dependency requires a version (often a pre-release or a just-unpublished one) that the registry no longer serves, so the range resolves to nothing.
A stale lockfile referencing a removed version
The committed lockfile encodes a version that was unpublished after the fact; a clean install can no longer find it.
How to fix it
Trace and pin the offending dependency
Find who requires the missing range and pin or override it to a version that exists.
npm view @acme/core versions --json
# pin the parent that pulls the bad range, or override:
npm install @acme/parent@latest
rm -f package-lock.json && npm installRegenerate the lockfile cleanly
- Delete
package-lock.jsonand reinstall so the tree resolves against current registry data. - If a transitive range is genuinely unsatisfiable, add an
overridesentry to a published version. - Commit the regenerated lockfile.
How to prevent it
- Avoid depending on pre-release ranges that can be unpublished.
- Use
overridesto pin unsatisfiable transitive ranges. - Regenerate the lockfile after upstream yanks.