Skip to content

[BUG] ^7.20.3 no longer resolves local package first on install (workspaces) #3637

@rijkvanzanten

Description

@rijkvanzanten

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

In a workspaces based environment, for example:

.
+-- package.json
`-- packages
   +-- a
   |   `-- package.json
   `-- b
       `-- package.json

Running npm install b --workspace a will no longer install the locally linked package correctly. Instead, it'll use the version hosted on npm, or throw a 404 if you use a custom (unique) package name.

Expected Behavior

In <7.20.x, NPM would resolve the local package, and correctly alter package.json and package-lock.json.

Steps To Reproduce

With node v16.6.1 and npm 7.20.3 installed:

  1. Make a new directory
mkdir ./npm-install-debug
  1. Add a package.json
cd ./npm-install-debug
npm init -y
  1. Setup 2 workspace packages
npm init -w ./packages/a
npm init -w ./packages/b

(I used @rijk/a and @rijk/b as names, to avoid confusion with the existing packages a and b.)

  1. Run npm install in the root, to give it a chance to npm link all the packages (not sure if needed)
npm install
  1. Try installing @rijk/b as a dependency of @rijk/a
npm install @rijk/b -w @rijk/a
  1. See error...
npm ERR! code E404
npm ERR! 404 Not Found - GET https://registry.npmjs.org/@rijk%2fb - Not found
npm ERR! 404
npm ERR! 404  '@rijk/b@*' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
npm ERR! 404
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/rijkvanzanten/.npm/_logs/2021-08-10T20_07_25_648Z-debug.log

If you install 7.20.2 or below (npm i -g [email protected]), the above flow still works as expected.

Environment

  • OS: macOS 11.4, also seen in GitHub Actions
  • Node: v16.6.1
  • npm: 7.20.3 and up

Metadata

Metadata

Assignees

Labels

Bugthing that needs fixingPriority 0will get attention right awayRelease 7.xwork is associated with a specific npm 7 release

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions