Enabling pnpm on V14.2 consuming more space

I was trying this new “faster” option introduced in 14.2, which says it reduce a lot the space consumed by node js lib.
I have 2 projects one big and one for testing, after adding
for production mode

 <configuration>
                    <pnpmEnable>true</pnpmEnable>
</configuration>

and for not production

@WebServlet(initParams = {
    @WebInitParam(name = "vaadin.pnpmEnable", value = "true")}
)

the folder node_modules increased their size to 500-700mb on each project, prior to the config this folder never went bigger than 400Mb, am I missing something in the configuration?

Afaik pnpm uses file system links so that every package version is only stored once on the disk even if the same dependency is used in several projects. The size you see might be different depending on how you’re looking it up. You might see the total size of files linked in node_modules, but total used disk space should be smaller if you have the same (or partially same) dependencies in many projects.

You could probably use some command (depending on your OS it’s probably different for Windows and Linux/macOS) to look up the project directory size excluding files that are linked from elsewhere to get a better understanding and then separately look at the size of your global pnpm cache directory and compare it to using npm which always copies the dependencies into each project directory.

One way you could check the real effect would be to look at space available on your disk/partition when using only npm or only pnpm for more than one project and then clear the global pnpm/npm caches and reinstall with the other method.

Hi,

I don’t know exactly what gets in to node_modules and what could create that difference, but comparing the size from filesystem inspector is bit problematic with pnpm. The files in node_modules with pnpm are actually hard links from the “computer local repository”. Thus it might quikly looking appear that it takes the same or more, but in fact the resources are only in one actual file on the fs. Check this FAQ for pnpm:

https://pnpm.js.org/en/faq

cheers,
matti

thanks, that FAQ explained it very well, Windows always the bad boy ¬¬