Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Node.js, PHP and APIs

npm install stops with notarget: no matching version found for a package

Errornpm ERR! notarget No matching version found for sockjs-client@0.0.0-unreleasable

Short answer

npm asked the registry for a version that does not exist. Run npm view on the package to list what is published. Then either change your range to a real version, or, when a dependency of a dependency asks for the bad one, pin a good version with overrides in package.json. Also confirm the registry is the one you expect.

  • Applies to npm 10, Node.js 22
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    List the versions that are really published for the package named in the error. If the version in the message is not in this list, the request itself is wrong.

    npm view sockjs-client versions
  2. 2Match what you see, then jump to its fix

    1. 1The package in the error is listed directly in your package.jsonYour own package.json asks for a version that was never publishedFix
    2. 2The package is not in your package.json but is in the error, and npm ls shows which parent wants itA dependency of one of your dependencies pins the missing versionFix
    3. 3npm view fails or shows a shorter list than the public one; a company mirror or old setting is in usenpm is talking to a registry or mirror that does not have the versionFix

What does the error look like?

  • npm ERR! notarget No matching version found for sockjs-client@0.0.0-unreleasable
  • npm ERR! notarget No matching version found for <package>@<version>

Cause 1 of 3

Your own package.json asks for a version that was never published

1Check

Compare the range in package.json with the list from npm view. A typo, a removed release or a pre-release tag that was never published all give this error.

grep -n "sockjs-client" package.json
npm view sockjs-client versions

2Fix

Set the dependency to a version that appears in the list (a caret range keeps compatible updates), then install again.

npm install sockjs-client@^1.6.1

3Verify

The install finishes without ETARGET and the package shows in the tree.

npm ls sockjs-client

Confirmed by docs.npmjs.com

Did this fix it?

Cause 2 of 3

A dependency of one of your dependencies pins the missing version

1Check

Find the parent that requests it, then decide whether a newer release of that parent fixes it.

npm ls sockjs-client

2Fix

In the root package.json, use overrides to force a version that exists. npm reads overrides only from the root project.

{
  "overrides": {
    "sockjs-client": "1.6.1"
  }
}

3Verify

Remove node_modules, install again, and check the tree.

rm -rf node_modules
npm install
npm ls sockjs-client

Confirmed by docs.npmjs.com

Did this fix it?

Cause 3 of 3

npm is talking to a registry or mirror that does not have the version

1Check

The default registry is https://registry.npmjs.org/. A different value in a project, user or global npmrc, or in the npm_config_registry variable, changes where npm looks.

npm config get registry
npm config ls -l | grep registry

2Fix

Set the registry back to the default for this project, or ask the owner of the mirror to sync the package.

npm install --registry=https://registry.npmjs.org/

3Verify

npm view now lists the version you need.

npm view sockjs-client versions

Confirmed by docs.npmjs.com

Did this fix it?

How do I stop it coming back?

  • Commit the lockfile, and use npm ci in CI so versions do not drift.
  • Use caret ranges that point at published releases, not copied pre-release strings.
  • Keep one registry setting per project in a committed .npmrc.

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

ng serve says it cannot determine the project or target

Cannot determine project for command.

The Angular CLI looked through angular.json for a project that defines the target you asked for (serve, build, test) and found none, or found several and could not pick one.

3 causes, each with a fix

Back end

ng serve cannot find the dev-server builder package

Could not find the implementation for builder @angular/build:dev-server

The builder named in angular.json (for example @angular-devkit/build-angular:dev-server) is looked up as an npm package starting from the workspace root.

3 causes, each with a fix

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.