Skip to content
New issue

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

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

Already on GitHub? # to your account

[BUG] Overrides with local dependencies produces different result depending on install-links flag #7867

Closed
2 tasks done
rH4rtinger opened this issue Oct 21, 2024 · 2 comments
Labels
Bug thing that needs fixing Needs Triage needs review for next steps

Comments

@rH4rtinger
Copy link

rH4rtinger commented Oct 21, 2024

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

Note: The used dependency is irrelevant.

I have a child and a project npm project.

In my child project have the following dependencies:

"dependencies": {
  "@types/semver": "^6.x"
}

In my project project I have this dependencies and an override:

"overrides": {
   "@types/semver": "^7.x"
  },
  "dependencies": {
    "@types/semver": "^7.x",
    "child": "../child"
  }

When I run npm i --install-links=true in my project and validating my installed dependencies with npm list --all, I only get version 7.x.

project_links_true@1.0.0 C:\dev\overrides_example\project_links_true
├── @types/semver@7.5.8 overridden
└─┬ child@1.0.0
  └── @types/semver@7.5.8 deduped

When I run npm i --install-links=false in my project and validating my installed dependencies with npm list --all, I get version 6.x from my child.

 project_links_false@1.0.0 C:\dev\overrides_example\project_links_false
├── @types/semver@7.5.8 overridden
└─┬ child@1.0.0 -> .\..\child
  └── @types/semver@6.2.7

Expected Behavior

I was expecting that overrides will work also for local dependencies as described in the documentation.

I expected that the dependency tree will only have version 7.x for my given dependency.

However, they only work so, when using the install-links=true flag.

I expected them to work as well with install-links=false.

Steps To Reproduce

I made also an example project, see https://github.com/rH4rtinger/override_example.

  1. Create a child project with the dependency stated above and run npm install in it.
  2. Create a parent project with the dependencies and override stated above and run npm install --install-links=false.
  3. Run npm list --all to show the dependency tree.

Environment

  • npm: 10.9.0
  • Node.js: 22.4.0
  • OS Name: Windows 10
  • System Model Name: Vostro 15 7510
  • npm config:
; "builtin" config from C:\Users\r.hartinger\AppData\Roaming\npm\node_modules\npm\npmrc

prefix = "C:\\Users\\r.hartinger\\AppData\\Roaming\\npm"

; "user" config from C:\Users\r.hartinger\.npmrc

loglevel = "info"

; node bin location = C:\Program Files\nodejs\node.exe
; node version = v22.4.0
; npm local prefix = C:\dev\overrides_example
; npm version = 10.9.0
; cwd = C:\dev\overrides_example
; HOME = C:\Users\r.hartinger
@rH4rtinger rH4rtinger added Bug thing that needs fixing Needs Triage needs review for next steps labels Oct 21, 2024
@kchindam-infy
Copy link

This is working as expected.

@wglanzer
Copy link

wglanzer commented Nov 7, 2024

@kchindam-infy Can you explain this behaviour a little bit deeper?
I do not understand, why this feature is working as expected - what is the "expected situation" here and why?

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Bug thing that needs fixing Needs Triage needs review for next steps
Projects
None yet
Development

No branches or pull requests

3 participants