While the default package manager for node is
npm, two other package managers are also supported by node:
npm is a good option, it can be limited for projects with a lot of dependencies, or with a lot of sub modules. In particular regarding installation time and disk space usage.
I’ll base myself on this A story of how we migrated to pnpm - ‹div›RIOTS which I find is a good summary of other results I could gather.
|Package Manager||Without cache||With cache|
|yarn 2 (without dedupe)||6min 31s||1min 11s|
|yarn 3 (without dedupe)||4min 50s||57s|
|yarn 3||4min 1s||50s|
|yarn 3 (optimized)||1min 10||45s|
- pnpm dependency installation is faster than the different versions and configurations of yarn
- pnpm is also less space consuming as each version is only stored once on the file system, and the actual
node_modulesstructure is based on hard-links to the stored modules
In addition, pnpm also prevents phantom dependencies:
Phantom dependencies are dependencies that you end up being able to use without explicitly depending on them. are dependencies that you end up being able to use without explicitly depending on them.
This is interesting as phantom dependencies can lead to unexpected breakage on dependency upgrade, as transitive dependencies can be removed without notice.
In conclusion, pnpm is both more performance and safer.
Therefore, I suggest to make it our package manager.