Skip to content

[BUG] overrides not working as expected in workspace #4205

@kturney

Description

@kturney

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

I am attempting to use the overrides support shipped in 8.3 within a project that also uses workspaces, but the dependency package version is not being overridden as expected.

My reading of the overrides RFC leads me to believe that maybe overrides is not currently supported within workspaces? If such is the case, then this may just be a documentation issue. Or maybe I am not correctly identifying the "root package.json file for a project" mentioned in the RFC.

I have tried placing my overrides in both the workspace's package.json and the package's package.json.
But none of these have successfully caused the package-lock.json to be generated with the overridden version after I run a fresh npm i from the workspace root.

If I add the overrides to the package's package.json and run npm i from within the package's directory, then the overrides functionality works as expected, but I lose the workspace functionality.

Expected Behavior

Given this workspace tree

workspace/
  a/
    ...
    package.json
  b/
    ...
    package.json
  package-lock.json
  package.json

in the package.json of package b (and where b has a dependency on node-zopfli) I expect to be able to put either

"overrides": {
  "prebuild-install": "^7.0.0"
},

or

"overrides": {
  "node-zopfli": {
    "prebuild-install": "^7.0.0"
  }
},

to cause prebuild-install@7 to be used instead of node-zopfli's request for prebuild-install@^5.3.5.
And I expect the package-lock.json in workspace to reflect this override.

Steps To Reproduce

  1. In this environment...
  2. With this config...
  3. Run '...'
  4. See error...

Environment

  • npm: 8.3.0
  • Node: 17.3.0
  • OS: macOS
  • platform: MacBook Pro
  • npm config:
; "user" config from /Users/kyle.turney/.npmrc

registry = "https://registry.npmjs.org/"

; "project" config from /Users/kyle.turney/dev/dc-flutter/lab_packages/.npmrc

audit = false
engine-strict = true
fund = false

; node bin location = /Users/kyle.turney/.volta/tools/image/node/17.3.0/bin/node
; cwd = /Users/kyle.turney/dev/dc-flutter/lab_packages
; HOME = /Users/kyle.turney
; Run `npm config ls -l` to show all defaults.

Metadata

Metadata

Assignees

Labels

Bugthing that needs fixingPriority 1high priority issueRelease 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