npm install stops with notarget: no matching version found for a package
npm ERR! notarget No matching version found for sockjs-client@0.0.0-unreleasableShort 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.
Fix it fast
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 versions2Match what you see, then jump to its fix
- 1
The package in the error is listed directly in your package.jsonYour own package.json asks for a version that was never publishedFix - 2
The 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
npm 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
- 1
What does the error look like?
npm ERR! notarget No matching version found for sockjs-client@0.0.0-unreleasablenpm 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 versions2Fix
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.13Verify
The install finishes without ETARGET and the package shows in the tree.
npm ls sockjs-clientConfirmed by docs.npmjs.com
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-client2Fix
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-clientConfirmed by docs.npmjs.com
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 registry2Fix
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 versionsConfirmed by docs.npmjs.com
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 fixBack end
ng fails with Cannot find module @angular/cli/bin/ng
Cannot find module '@angular/cli/bin/ng'
The ng command is the entry point to the Angular CLI package.
2 causes, each with a fixBack end
Angular app shows 'Cannot GET /' when served by a Node.js server
Cannot GET /dashboard
Cannot GET / is Express saying no route or file matches the request.
3 causes, each with a fixBack 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 fixBack end
Angular build says it cannot resolve '@angular/localize/init'
Can't resolve '@angular/localize/init' in '/usr/src/app/src'
The build imports @angular/localize, and that package is not in node_modules.
2 causes, each with a fixBack end
The command npm run build -- --prod exited with code 1 (Angular)
The command "npm run build -- --prod" exited with code 1
Exit code 1 only says the build failed; the real message is above it.
2 causes, each with a fix