DEV Community

Cover image for What is pnpm? Is it really so fast and space-efficient?

What is pnpm? Is it really so fast and space-efficient?

Sylwia Vargas on October 13, 2022

We announced at ViteConf that our WebContainers now support pnpm. It was a major achievement in our commitment to support the Vite ecosystem as man...
Collapse
 
derlin profile image
Lucy Linder

Very interesting, thanks!
How does pnpm manages cleanup though? With npm, you delete the project folder, and node_modules disappear. Is pnpm able to detect some deps in the cache are now dangling and useless?
If not, does it mean cleanup requires deleting the pnpm folder, and re-run pnpm install on all projects? (which no one will do and thus the pnpm folder may grow indefinitely?)

Collapse
 
sylwiavargas profile image
Sylwia Vargas StackBlitz

Thank you for your questions, @derlin!

Yes, the pnpm cache grows indefinitely basically but there is usually a lot of overlap of dependencies between projects. Pruning the store every once in a while is a good idea. You can do it via pnpm store prune, which removes unreferenced packages that are not used by any project.

Collapse
 
ndaidong profile image
Dong Nguyen

great question, I use pnpm daily and I see it has pnpm prune command, but I never tested it. If it works as same as docker volume prune, it's exactly what we need.

Unfortunately, even the document:

Removes unnecessary packages

It doesn't seems easy to understand how it actually works.

Image description

May Sylwia help us to clarify?

Collapse
 
sylwiavargas profile image
Sylwia Vargas StackBlitz

Thank you, @ndaidong! I think we posted at the same time - yes, you're right about pnpm prune!

Thank you for your questions, @derlin!

Yes, the pnpm cache grows indefinitely basically but there is usually a lot of overlap of dependencies between projects. Pruning the store every once in a while is a good idea. You can do it via pnpm store prune, which removes unreferenced packages that are not used by any project.

Thread Thread
 
ndaidong profile image
Dong Nguyen

You're rock! We need pnpm store prune. Just cleaned :)

Image description

Collapse
 
harithzainudin profile image
Muhammad Harith Zainudin

This really open my eyes about pnpm.
Ive been only using npm, and not looking at others as i felt it unnecessary. But its tempting to test out and try using pnpm because why not right? hahaha

Would definitely try it! Thanks @sylwiavargas!

Collapse
 
sylwiavargas profile image
Sylwia Vargas StackBlitz

Ah thank you for sharing this! I'm happy this post brought some clarity and curiosity 💕

Collapse
 
madza profile image
Madza

Insightful and a great alternative 👍✨

Collapse
 
sylwiavargas profile image
Sylwia Vargas StackBlitz

Thank you!

Collapse
 
Sloan, the sloth mascot
Comment deleted
Collapse
 
thi3rry profile image
Thierry Poinot

Could you say more about that ?

Collapse
 
Sloan, the sloth mascot
Comment deleted
 
sylwiavargas profile image
Sylwia Vargas StackBlitz

Would you provide links where this is documented?
I've set my VPN to Belarus and I'm able to run it.

Thread Thread
 
Sloan, the sloth mascot
Comment deleted
 
thi3rry profile image
Thierry Poinot

Ok I see, I think he is mentioning the pnpm decision on twitter : https://twitter.com/pnpmjs/status/1498306992577957890?s=46&t=0bwOqnztoi2cUIkmGvGBow

Collapse
 
dvdvdmt profile image
Dmitriy Davydov • Edited

So, if you don't need the 3x speed increase for the dependencies installation and don't want to reduce some disc space consumption then you can continue to be happy with npm 🤷‍♂️
There is a feature parity between pnpm and npm, but the later wins because it is shipped with Node and it has much broader adoption. I think that all the innovation from the pnpm eventually will come to the npm, it is just a matter of time.

Collapse
 
sylwiavargas profile image
Sylwia Vargas StackBlitz

you can continue to be happy with npm

Yes! It's always good continue to be happy with whatever makes you happy 🙂
I appreciate your optimism about npm roadmap - let's hope it will be that way.