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

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

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

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

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

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

Thread Thread
 
sylwiavargas profile image
Sylwia Vargas • Edited

Yes, I see that on my end as well. Given that the author of pnpm is from Ukraine and still in Ukraine, I don’t find this surprising.

(EDIT: I see that he was also open about this decision so nothing sneaky there)

However, you were talking about CLI - could you provide links?

Blocking a website based on the location is not a security threat, especially if the website and docs are open sourced and accessible on GitHub.

Thread Thread
 
Sloan, the sloth mascot
Comment deleted
 
sylwiavargas profile image
Sylwia Vargas • Edited

I hear you and what you’re saying is not overlapping with the experience of my friend in Belarus nor with my experience on VPN. Would you provide links to where this issue is documented?

You also mentioned this as “childishness” and “serious project” but this is a common practice in tech - whether it’s good or bad, that’s a subject for opening a discussion. To give you an example, GitHub blocked Devs from Iran, Syria, and Crimea two years ago and here’s a whole list of serious business blocking Iran. Here’s a Wikipedia entry on GitHub’s track record in this field. It is a common practice by the protect authors or whole businesses.

A discussion about political decisions of a project or a business and its merits is one thing. You’re throwing an accusation without documentation. I’m not saying that what you’re saying is not true but so far I haven’t managed to see evidence of that and you’ve avoided providing me with one, even if it’s a link to an issue or a tweet which engaged Zoltan. Moreover, Zoltan was asked if the CLI will be affected:

to which he responded:

I understand that a decision like this is bound to trigger responses and emotions - and it’s fair to express them.

Thread Thread
 
zkochan profile image
Zoltan Kochan • Edited

As Sylwia already stated, only the website with the docs is blocked. The CLI works. Also, the standalone install script doesn't work because it is a script from the website. Other install methods work, like corepack enable and npm i -g pnpm.

However, if companies in Russia and Belarus decide not to use pnpm, my goal is achieved. I don't want my work to help such companies and people. I live in Ukraine, my life is in constant danger because of Russia and Belarus.

Thread Thread
 
spock123 profile image
Lars Rye Jeppesen

Slava Ukraini

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

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.