npm / npm/rfcs

[RRFC] Add automatically installed peer deps to `package.json`

Open
#384 5 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
777
Forks
267
PR merge metrics
No merged PRs in 30d

Description

Motivation

Currently, when I install a package with peer dependencies in npm 7, they will automatically be installed and added to the package-lock.json. I think those peer deps should also be added to package.json, mimicking someone manually installing them. It would be nice to see which packages are installed in my project, especially when they are at the top level, otherwise, it feels like too much magic is going on that I cannot see.

Example

Say I have a package named foo with the peer dependencies bar and baz. I have not added any other packages to my project. bar and baz will then be automatically installed at the top level by npm (7), but they will not be included in package.json. I want them to be included in package.json so I can get a good overview of the(top-level) packages installed.

How

Add the automatically installed peer dependencies to package.json.

Current Behaviour

Peer dependencies are "magically" installed in the project and I cannot trust the package.json file to show me all packages installed.

Desired Behaviour

Add the automatically installed peer dependencies to package.json.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing npm 7's automatic peer-dependency installation behavior and the discussion on this RFC. Define how automatically installed top-level peer dependencies should be represented in package.json, while preserving the package-lock.json behavior; the desired result is that package.json shows those installed packages explicitly.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
cli, tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.