Skip to content

[RRFC] --save-peer flag #95

@ruyadorno

Description

@ruyadorno

This was brought up by @ljharb during one of our conversations and I'm putting up this RRFC in order to collect early comments and see if anyone can expand upon it and submit a proper RFC in the future.

Essentially the idea here is that it would be nice for the cli to have a more robust or advanced support to saving peer deps ranges from the cli rather than manually handling the package.json file.

npm install [email protected] --save-peer
# would yield a "react": "16.0 || 16.2" in package.json as result
# in a diff package.json containing react as a dep with a range: `~16.0 || ~16.1`
npm install react@~16.5 —save-peer # appends the new range
# would yield a "react": "~16.0 || ~16.1 || ~16.5" in package.json as result

# in that same package.json now forces a diff version
npm install react@~16.5 —save-peer -f # forces semver range
# would  yield a "react": "react": "~16.5" as a result

This type of support can be handy within a workspaces/monorepo setup allowing users to easily manage ranges for peer deps of multiple packages at once.

/cc @npm/cli-team

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions