Skip to content

[BUG] npm install generates wrong overrides link #5584

@szmarczak

Description

@szmarczak

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

node_modules/print is linked to ../hello/print

Expected Behavior

node_modules/print should be linked to ../print

Steps To Reproduce

git clone https://github.com/szmarczak/npm-overrides-bug && cd npm-overrides-bug

# This does not work, but should
cp package.json.error package.json && npm install && node index.js

# This works
cp package.json.ok package.json && npm install && node index.js

If successful, it will output Hello, world!. If not successful, it will output Error: Cannot find module 'print'

Environment

  • npm: 8.19.1
  • Node.js: v18.9.0
  • OS Name: Ubuntu
  • System Model Name: doesn't matter
  • npm config:
$ npm config ls
; "user" config from /home/szm/.npmrc

//registry.npmjs.org/:_authToken = (protected) 

; node bin location = /home/szm/.nvm/versions/node/v18.9.0/bin/node
; node version = v18.9.0
; npm local prefix = /tmp/test
; npm version = 8.19.1
; cwd = /tmp/test
; HOME = /home/szm
; Run `npm config ls -l` to show all defaults.

Metadata

Metadata

Assignees

Labels

Bugthing that needs fixingNeeds Triageneeds review for next stepsRelease 8.xwork is associated with a specific npm 8 releaseconfig:overridesIssues dealing with the overrides feature

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions