Nextjs + PNPM ( performant nodejs package manager )
Benchmark in pnpm package manager with nextjs
Check which is fast npx and pnpm to install nextjs.
PNPM is a new nodejs package manager like npm and yarn. Today I’m campers nextjs installation time in npx and pnpm.
npx use by default yarn to install the nextjs. For the time stamp, I’m using the Linux time
command. time
the command tells the actual uses of programs time and summarises system resource usage time.
https://linuxize.com/post/linux-time-command/
Installation of pnpm
I’m testing pnpm base on two parameters.
- Size
- Caches
Size
One thing is very odd for me that is the size of the fresh install nextjs project with npx and pnpm. The size of npx and pnpm is the same. I think pnpm helps reduce the size of a new project, but it does not work as I expected.
I install more than 6 to 8 new projects with npx and pnpm. Every time the size new installation folder is the same.
In pnpm, maybe the size of the folder is reduced in the other package. But nextjs, it does not work.
Caches
First, install nextjs without caches and see how much nextjs take time to install with pnpm and npx. The second time we install nextjs and see how much it takes time to install nextjs.
NPX benchmark without caches
rajdeepsingh@officialrajdeepsingh:~/working$ time npx create-next-app@latest
real 8m26.886s
user 0m55.394s
sys 0m27.210s
PNPM benchmark without caches
rajdeepsingh@officialrajdeepsingh:~/working$ time pnpm create next-app
real 2m36.691s
user 0m28.880s
sys 0m6.290s
PNPM benchmark with caches
rajdeepsingh@officialrajdeepsingh:~/working$ time pnpm create next-app
real 1m32.419s
user 0m8.758s
sys 0m2.464s
NPX benchmark with caches
rajdeepsingh@officialrajdeepsingh:~/working$ time npx create-next-app@latest
real 1m53.513s
user 0m10.031s
sys 0m4.523s
Faq
Why I’m comparing nextjs base of npx and pnpm
Many developers use npx to install nextjs in daily life, and the nextjs team recommended using npx to start a new or fresh project.
Summaries
For small projects, it does not matter what should use npx or pnpm. Both work the same. If your work folder is big, then I recommend using pnpm
in your nextjs project.
The test result is not the same every time. Lots more factors affect npx and pnpm. I test on online cloud IDE is test changes. But one thing is considered the time of pnpm is very less as compared to npx
for the first installation.
In one case, pnpm takes less time when we install a new project, and the project package does not have any per caches stored in the machine.
The second time, npx, yarn, and pnpm take store cache locally in the machine. It takes the same and equal time for the new installation of the nextjs project.