Skip to content

[BUG] npm dedupe is broken when used in conjunction with workspaces for all versions >=7.20.3 #4168

@hzuo

Description

@hzuo

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

Inside an npm workspace, with packages package-a and package-z, if package-a depends on package-z, running npm dedupe will fail with the following error:

❯ npm dedupe
npm ERR! code E404
npm ERR! 404 Not Found - GET https://registry.npmjs.org/package-z - Not found
npm ERR! 404
npm ERR! 404  'package-z@*' is not in this registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
npm ERR! 404
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.

npm dedupe attempts to look up the sibling package in the remote npm registry rather than within the workspace itself.

Expected Behavior

npm should first look among the packages in the workspace before looking for a package in the remote registry.

Steps To Reproduce

Here's the repro for the bug:
https://github.com/hzuo/test-dedupe-workspaces

Simply run npm install and then npm dedupe to repro.

Environment

  • npm: 8.3.0
  • Node: 16.13.1
  • OS: macOS Big Sur 11.6
  • platform: Macbook Pro
  • npm config:
; node bin location = /Users/hzuo/.nvm/versions/node/v16.13.1/bin/node
; cwd = /Users/hzuo/git/tmp/test-dedupe-workspaces
; HOME = /Users/hzuo

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bugthing that needs fixingNeeds Triageneeds review for next stepsRelease 8.xwork is associated with a specific npm 8 release

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions