Error Knowledge Base NPM ETARGET

npm ERR! code ETARGET

npm could not find a version that matches the requested semver range or dist-tag.

Affected versions: All supported npm versions.

What This Error Means

npm could not find a version that matches the requested semver range or dist-tag.

How to Fix It

  1. Check which registry npm is using: npm config get registry.
  2. If the package is scoped, verify scope registry mapping in .npmrc (example: @your-scope:registry=...).
  3. List available versions: npm view <pkg> versions --json.
  4. If you requested a dist-tag, list tags: npm view <pkg> dist-tags --json.
  5. Retry with npm --verbose if the error message is truncated.

Why It Happens

  • The configured registry does not contain the package/version you requested.
  • Auth is missing for a private registry or scoped package.
  • The requested version/tag/range is invalid or does not exist.

How to Verify

  1. Re-run npm view <pkg> for the same registry and confirm metadata is accessible.
  2. Re-run the original install and confirm the resolution error no longer appears.

Manual dependency inspection

  1. Check which registry npm is using: npm config get registry.
  2. If the package is scoped, verify scope registry mapping in .npmrc (example: @your-scope:registry=...).
  3. Query the registry directly for metadata: npm view <pkg>@<version> --json.

Common CLI Output

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

How npm resolves dependencies

  1. npm resolves packages by fetching metadata from the registry, then selecting versions that satisfy semver ranges.
  2. Private registries and scopes add auth and routing requirements via .npmrc.
  3. If metadata lookup fails or no version satisfies constraints, npm throws a resolution error.

Prevention Tips

  • Keep registry config and auth in .npmrc under version control (where appropriate).
  • Pin versions (or use lockfiles) to avoid unexpected tag/range changes.
  • Prefer a proxy/cache registry for CI stability.

Where This Can Be Triggered

github.com/npm/cli/blob/417daa72b09c5129e7390cd12743ef31bf3ddb83/lib/commands/outdated.js

Open-source npm CLI code reference tied to this error code. - GitHub

    } catch (err) {
      // silently catch and ignore ETARGET, E403 &
      // E404 errors, deps are just skipped
      if (!['ETARGET', 'E404', 'E404'].includes(err.code)) {
        throw err
      }
    }

Need help or found a mistake? Contact RepoFlow support for questions.

Join our mailing list