Level - Intermediate. Read Time ~ <5 minutes.
Updated - 29/04/2018. Based on feedback from Zoltan.
- PNPM performs well without cache and with existing node modules. But does not perform well with cache or shrinkwrap file.
- NPM install performs better without cache than with cache.
- Yarn is the slowest without cache. But performs very well with cache or existing node modules.
Comparing Node Package Managers
After the release of
npm ci, specifically for Continuous Integration environments. I noticed this was significantly faster than a standard
npm install. It's worth noting you need at least NPM 5.7.0 to have the
ci cli command available for use.
I set out comparing the following package managers with and without cache, without lock files and with existing node modules: -
Both Yarn and PNPM claim their package managers are the fastest out there. I'm not judging the credibility of the authors of these package managers and their contributors. But I wanted to do my own due diligence. I will share my findings below.
For my tests I ran the following bash script on my MacBook Pro, 2.2ghz Core i7, 16GB RAM. It was run on a home broadband connection over WiFi on a download connection speed of 15.8 mbps. To expand more on my local setup, I was running the following versions: -
- NodeJS - 8.11.1
- NPM - 6.0.0
- Yarn - 1.6.0
- PNPM - 1.41.2
The repo I used was https://github.com/blairg/hapi-socket-react-boilerplate.
The script I ran to generate the benchmarks can be found here.
Raw results can be found below: -
The next thing I did was to collate these in an Excel spreadsheet with some graphs to help with visibility.
From my testing
npm ci came out a clear winner. If my tests are not valid or I missing something, I'm more than happy to be corrected. Comments below please.
I'm not suggesting suddenly move off Yarn, but thought this was an interesting exercise if you are looking to save valuable seconds on CI builds. If you read Zoltan comments below regarding PNPM, the advantage of PNPM becomes greater on larger projects, with many modules. You can see additional benchmarks here.
Subscribe to Hackerlite
Get the latest posts delivered right to your inbox