A command/param to install a package's peer dependencies or to add them to packages.json #11213
Comments
Seems like a good idea to me. I actually really like the idea of How about something like:
And
Thoughts? 💭 |
Any I'd call for putting as little magic into it, and making it explicit. Going with that, I think using |
Thanks for the discussion! The team spent a while discussing this, and while we agree that something like this would be useful, the CLI team isn't going to have the time to work on it in the next 6-12 months, so I'm going to close this feature request. However, this seems like it might be useful enough that if somebody wanted to put it together as a patch, we'd be happy to land it. We even have some thoughts about what it might look like!
It would also be pretty easy to create a small wrapper script to migrate packages as a one-off, and that wouldn't require any changes to npm at all. In any case, if you want to work on this, please do, and feel free to ask us questions or to open a pull request pretty early in the process if you want more support from the team. Our time is limited, but we have lots of it for the community! |
@othiym23 - It is looking like this has some traction on Twitter, would it not make sense to keep the issue open for discussion of the spec for implementation by the community? |
@joshtoo There are over 350 feature requests open on this issue tracker right now, with more being filed all the time. The CLI team is going to have the wherewithal to get to maybe 20-30 in the next year. The CLI team's current policy is to leave open only those feature requests we intend to ship, so that it's clearer to users what the team is actually working on, and is planning to work on soon. We put |
@othiym23 - Fair enough, thanks for the clarification. |
A couple of ways to do this (someone asked, so I code golfed an answer): With basic sed: npm info . peerDependencies | sed -n 's/^{\{0,1\}[[:space:]]*'\''\{0,1\}\([^:'\'']*\)'\''\{0,1\}:[[:space:]]'\''\([^'\'']*\).*$/\1@\2/p' | xargs npm i ... or, if you already have jq -r '.peerDependencies | to_entries[] | .key + "@" + .value' package.json | xargs npm i |
…amically look up the right version numbers when installing peer deps. Fixes #956. This command would be simpler if npm/npm#11213 is ever implemented.
That PKG=eslint-config-airbnb npm info "$PKG" peerDependencies --json | command sed 's/[\{\},]//g ; s/: /@/g' | xargs npm install --save-dev "$PKG" which seems to reliably produce and run the command I want. See airbnb/javascript@623dc44 for reference. |
Any progress on this? Can we reopen? |
…amically look up the right version numbers when installing peer deps. Fixes airbnb#956. This command would be simpler if npm/npm#11213 is ever implemented.
If anyone comes across this, I wrote a cli program to do this as well:
It works cross-platform (and with both Yarn and NPM) - if you have any problems with it feel free to open an issue on the repo! |
…amically look up the right version numbers when installing peer deps. Fixes airbnb#956. This command would be simpler if npm/npm#11213 is ever implemented.
…amically look up the right version numbers when installing peer deps. Fixes #956. This command would be simpler if npm/npm#11213 is ever implemented.
Let me take
angular2
package as example (I know it's not final, but it's good for demonstrating the current issue).It has the following peer dependencies:
Arguably at least some of these are rightfully peer dependencies (In the sense that they need to be top-level dependencies to be used by consuming project, in other words, flat dependencies).
Of course when I install it I get the messages about missing peer dependencies. I have read about this in #6565 and that's alright.
Problem
When there are few of these dependencies, it gets a bit silly to copy/paste the name of each one to install them (I have also seen it in a recent comment on #5080).
Proposal
Is it possible to add a flag to
npm
install
command that installs peer dependencies as well?We would still have the default / implicit experience surprise-free, but also make it easier for those who explicitly want to opt-in and install those peer dependencies.
Another option might be:
npm
command that installs peer dependencies, or at least adds them to `packages.Thoughts?
The text was updated successfully, but these errors were encountered: