npm / npm/cli

[BUG] npm install a specific package version in workspaces do not work as expected

Open
#6,533 4 comments 18 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Bug Needs Triage Release 9.x
Dominant language
JavaScript
Stars
10.1k
Forks
4.7k
Avg merge
2d 2h
Merged PRs (30d)
19

Description

Is there an existing issue for this?
  • I have searched the existing issues
This issue exists in the latest npm version
  • I am using the latest npm
Current Behavior

I have two workspaces workspace_a and workspace_b using the same package dependency_a with different versions.

Changing the version of dependency_a in workspace_a using npm i dependency_a@version -w workspace_a have no effect and the version is not changed

Expected Behavior

Running npm i dependency_a@version -w workspace_a should change the version of dependency_a in workspace_a to the request version.

Steps To Reproduce
// Initialize project
$ npm init

// Initialize workspaces
$ npm init -w ./packages/a -w ./packages/b

// Install react 17 in all workspaces
npm install react@17.0.2 --workpaces

// Install react 18 in workspace a
npm install react@18.2.0 --workspace a

// Install back react 17 in workspace a
npm install react@17.0.2 --workspace a

The last command to install react with version 17 to workspace a have no effect, and workspace a still use react 18 at this point. The output of the last command is:

up to date, audited 10 packages in 709ms

found 0 vulnerabilities
Environment
  • npm: 9.5.1
  • Node.js: v18.16.0
  • OS Name: MacOS 12.5
  • System Model Name: Macbook Pro

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the issue with the listed npm init and workspace commands on npm 9.5.1 and Node.js v18.16.0. Compare workspace a after installing react@18.2.0 and then react@17.0.2; done means the final command changes workspace a to the requested version.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, nodejs
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.