Skip to content

[BUG] npm with workspaces fails to install dependencies using dist tags #8252

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
2 tasks done
vividviolet opened this issue Apr 23, 2025 · 2 comments
Open
2 tasks done
Labels
Bug thing that needs fixing Priority 2 secondary priority issue

Comments

@vividviolet
Copy link

vividviolet commented Apr 23, 2025

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

Running npm install in a workspace with package A using preact@latest and package B using preact@experimental only installs preact@latest.

Expected Behavior

Each package should install its own version of the dependency matching the dist tag.

Steps To Reproduce

In a workspaces based environment, for example:

packages.json

{
  "name": "example",
  "version": "1.0.0",
  "license": "UNLICENSED",
  "workspaces": [
    "packages/*"
  ]
}

packages/a/package.json

{
  "name": "a",
  "version": "1.0.0",
  "license": "UNLICENSED",
  "dependencies": {
    "preact": "experimental"
  }
}

packages/b/package.json

{
  "name": "b",
  "version": "1.0.0",
  "license": "UNLICENSED",
  "dependencies": {
    "preact": "latest"
  }
}
  1. Run npm install
  2. Run npm ls --package-lock-only
  3. Observe that it incorrectly dedupes preact to pull only 10.26.5 from latest
├─┬ [email protected] -> ./packages/a
│ └── [email protected]
└─┬ [email protected] -> ./packages/b
  └── [email protected] deduped
  1. Modify a's dependency to use a version
    packages/a/package.json
{
  "name": "a",
  "version": "1.0.0",
  "license": "UNLICENSED",
  "dependencies": {
    "preact": "11.0.0-experimental.1"
  }
}
  1. Modify b's dependency to use a version
    packages/b/package.json
{
  "name": "a",
  "version": "1.0.0",
  "license": "UNLICENSED",
  "dependencies": {
    "preact": "10.26.5"
  }
}
  1. Run npm install
  2. Run npm ls --package-lock-only
  3. Observe that it now has the correct dependencies for both packages
├─┬ [email protected] -> ./packages/a
│ └── [email protected]
└─┬ [email protected] -> ./packages/a
  └── [email protected]

Environment

  • npm: 10.9.2
  • Node.js: v23.7.0
  • OS Name: MacOS Sequoia 15.3.1
  • System Model Name: Macbook Pro
@vividviolet vividviolet added Bug thing that needs fixing Needs Triage needs review for next steps labels Apr 23, 2025
@milaninfy milaninfy added Priority 2 secondary priority issue and removed Needs Triage needs review for next steps labels Apr 30, 2025
@milaninfy
Copy link
Contributor

able to reproduce locally.

@chestnutchen
Copy link

I encountered the same issue using beta instead of experimental. This approach has not worked since npm v7.x, and I couldn't find any documentation regarding the support or deprecation of this feature. Though it seems similar to running npm install preact@beta or npm install preact@experimental, I'm still uncertain why this functionality was suddenly unsupported.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug thing that needs fixing Priority 2 secondary priority issue
Projects
None yet
Development

No branches or pull requests

3 participants