The npm community forum has been discontinued.
To discuss usage of npm, visit the GitHub Support Community.
Removed peer dependency doesn't be reinstalled
What I Wanted to Do
Remove a peer dependency and get it back when reinstall packages
What Happened Instead
When I reinstall all packages (npm i), the peer dependency was not reinstalled
I’ll use Firebase and angularfire to show. In any npm project folder:
$ npm install angularfire $ npm uninstall firebase <!-- peer dependency from angularfire --> $ npm install
Look that the firebase dependency was not installed again.
My suggestion is to allow remove explicit only dependencies on package.json (yarn behavior). Unnecessary inconsistencies can be avoided with this.
But, if community like/use that feature, updating package-lock when a peer dependency is removed must do the job.
OS: Manjaro Linux
Are you sure firebase was uninstalled?
npm allows the package.json to specify
angularfire lists firebase in its
dependencies. When you install angularfire you get firebase too.
$ npm init -y ... $ npm install angularfire ... $ npm ls $ npm ls firebase firstname.lastname@example.org /Users/john/Documents/Sandpits/npm.community/9961 └─┬ email@example.com └── firstname.lastname@example.org
When you uninstall firebase, since it is not a direct dependency of your package, it does not get uninstalled.
$ npm uninstall firebase ... $ npm ls firebase email@example.com /Users/john/Documents/Sandpits/npm.community/9961 └─┬ firstname.lastname@example.org └── email@example.com
On a related note, peerDependencies are not automatically installed since npm v3 but there is a proposal to bring that back: https://github.com/npm/rfcs/pull/43
I can’t reproduce again and you’re right, firebase wasn’t uninstalled. I don’t know what I actually did… An info message saying that dependency was keeped is valid? wdyt?
Anyway, this was my confusion and the problem was solved, thanks!