Skip to content
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

[BUG] presence of overrides prevents hoisting when updating workspace dependencies #7019

Open
2 tasks done
jenseng opened this issue Nov 22, 2023 · 0 comments
Open
2 tasks done
Labels
Bug thing that needs fixing config:overrides Issues dealing with the overrides feature Release 10.x

Comments

@jenseng
Copy link
Contributor

jenseng commented Nov 22, 2023

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

If the root package.json defines any overrides, if you attempt to update a hoisted workspace dependency (either via npm install <specifier> --save-exact -w <workspace> or by editing its package.json and running npm install), it always becomes un-hoisted, even if you have set prefer-dedupe=true

This is a contributing factor to #7018 and #7028

Expected Behavior

Packages should generally be hoisted, especially when prefer-dedupe=true.

If you remove the root-level overrides, it works as expected.

Steps To Reproduce

Given package.json:

{
  "workspaces": [
    "packages/*"
  ],
  "overrides": {
    "doesnt-matter-can-be-anything": "1.2.3"
  }
}

And packages/my-cool-package/package.json:

{}

Run:

  • npm i tiny-invariant@0.0.2 --save-exact -w my-cool-package (hoisted to node_modules/tiny-invariant) ✅
  • npm i tiny-invariant@0.0.3 --save-exact -w my-cool-package (un-hoisted to packages/my-cool-package/node_modules/tiny-invariant) ❌

Note that if you npm i tiny-invariant@... --save-exact -w my-cool-package a third time, it will re-hoist it 🤔 (and un-hoist it the fourth time, etc.)

Environment

  • npm: 10.2.4
  • Node.js: 18.17.1
  • OS Name: Mac OS Ventura
  • System Model Name: Macbook Pro
  • npm config:
prefer-dedupe = true
registry = "https://registry.npmjs.org/"
@jenseng jenseng added Bug thing that needs fixing Needs Triage needs review for next steps Release 10.x labels Nov 22, 2023
@jenseng jenseng changed the title [BUG] presence of overrides prevents hoisting when upgrading workspace dependencies [BUG] presence of overrides prevents hoisting when updating workspace dependencies Nov 22, 2023
@lukekarrys lukekarrys added config:overrides Issues dealing with the overrides feature and removed Needs Triage needs review for next steps labels May 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug thing that needs fixing config:overrides Issues dealing with the overrides feature Release 10.x
Projects
None yet
Development

No branches or pull requests

2 participants