Skip to content

[BUG] installing a dependency in a package with a peer dependency changes the peerDependencies field #2735

Closed
@targos

Description

@targos

Current Behavior:

If you have a package with something in peerDependencies and then install that something in the same package as a devDependency, the peerDependencies field is changed and the dependency is added to package.json, but it inherits the semver string that the peer dependency had.

Expected Behavior:

Installing a dev dependency should do the same change to the package.json, whether that dependency is already in peerDependencies or not.

Steps To Reproduce:

echo '{ "peerDependencies": { "typescript": "*" } }' > package.json
npm i -D typescript
cat package.json
{"peerDependencies":{"typescript":"^4.1.5"},"devDependencies":{"typescript":"*"}}

Environment:

  • OS: macOS
  • Node: 15.8.0
  • npm: 7.5.4

Metadata

Metadata

Assignees

No one assigned

    Labels

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

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions