Using package.json file to install using npm and pnpm command. This separate to 3 scenario: fresh install, no node_modules, and with node_modules
MacBook: 13-inch, M1, 2020 16GB
MacOS: 13.4.1 (22F82)
NodeJS: v18.16.1
Npm: 9.5.1
Pnpm: 8.6.7
Fresh install will install from directory that contains only package.json (no caches nor lock file).
time npm install
reference: https://app.warp.dev/block/pURqfKRL88GWtlP1DgxUIv
Total usage time: 1m7.65s
rm -r /tmp/.pnpm-store
time pnpm \
--store-dir /tmp/.pnpm-store \
--loglevel warn install
reference: https://app.warp.dev/block/62Oq5acKquq14GVb5tvPrt
Total usage time: 52.198s
This run without node_modules, but might include caches (if any).
rm -r node_modules
time npm install
reference: https://app.warp.dev/block/OfKnsDcDEWAJp4gjQgdzi1
Total usage time: 11.39s
rm -r node_modules
time pnpm \
--store-dir /tmp/.pnpm-store \
--loglevel warn install
reference: https://app.warp.dev/block/6g7AJcbxvYEcDfITPZwu1I
Total usage time: 10.254s
This simulate seconds run on installed package.
time npm install
reference: https://app.warp.dev/block/7Ib6sztjs78HSpaaTUDIwm
Total usage time: 2.064s
time pnpm \
--store-dir /tmp/.pnpm-store \
--loglevel warn install
reference: https://app.warp.dev/block/7IapuYqh3YHXaI5LXF4jlE
Total usage time: 0.743s
On all tests, pnpm is faster than npm.
Testcase | Npm | Pnpm | % Diff |
---|---|---|---|
Fresh install | 1m7.65s | 52.198s | 29.60% |
Without node_modules | 11.39s | 10.254s | 11.08% |
With node_modules | 2.064s | 0.743s | 177.79% |