Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
targos opened this issue Feb 19, 2021 · 4 comments
Labels
Bug thing that needs fixing Needs Triage needs review for next steps Release 7.x work is associated with a specific npm 7 release

Comments

@targos
Copy link
Contributor

targos commented Feb 19, 2021

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
@targos targos added Bug thing that needs fixing Needs Triage needs review for next steps Release 7.x work is associated with a specific npm 7 release labels Feb 19, 2021
@ljharb
Copy link
Contributor

ljharb commented Feb 19, 2021

npm warns when moving a dep between dev and prod; I’d hope if you attempt to install a dev dep and a peer dep exists, that it at least informed you of that.

@nlf
Copy link
Contributor

nlf commented Apr 9, 2021

as mentioned, we print a warning when this happens. in addition to that we've made some improvements to how peer dependencies are added and saved that i believe should address this problem.

@nlf nlf closed this as completed Apr 9, 2021
@targos
Copy link
Contributor Author

targos commented Apr 11, 2021

I tried again with npm 7.9.0 and no warning is printed. I'd like this issue to be reopen because nothing has changed since I opened it.

@targos
Copy link
Contributor Author

targos commented Apr 18, 2021

Reopened at #3096

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug thing that needs fixing Needs Triage needs review for next steps Release 7.x work is associated with a specific npm 7 release
Projects
None yet
Development

No branches or pull requests

3 participants