Skip to content

[BUG] npm audit fix adds redundant dependencies in workspaces #7950

@jlin-appaegis

Description

@jlin-appaegis

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

An additional package is added as a dependency to existing workspaces, even though it is not listed as a dependency of the existing workspace in the package.json originally.

Expected Behavior

npm audit fix --force should only upgrade existing vulnerable dependencies. It should NOT add new dependencies to workspaces unless explicitly defined in the package.json originally.

Steps To Reproduce

  1. Clone the example repository
  2. Install dependencies using npm ci.
  3. Run npm audit fix --force to address all vulnerabilities.
  4. The additional @swc/cli is added to the workspace package-a, however, the workspace package-a doesn't need it.

Environment

  • npm: 10.9.1
  • Node.js: 21.5.0
  • OS Name: macOS 14.6.1
  • System Model Name: Macbook Pro 14-inch, 2021
  • npm config:
; "user" config from /Users/jamie/.npmrc

; node bin location = /Users/jamie/.nvm/versions/node/v21.5.0/bin/node
; node version = v21.5.0
; npm local prefix = /Users/jamie/Sources/monorepo
; npm version = 10.9.1
; cwd = /Users/jamie/Sources/monorepo
; HOME = /Users/jamie
; Run `npm config ls -l` to show all defaults.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bugthing that needs fixingPriority 2secondary priority issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions