I started using pnpm for my Electron project because it is faster than npm
or yarn
. As far as I can see it creates all modules first in project/node_modules/.pnpm
and all packages in project/node_modules
refer to a module inside the .pnpm
directory.
This is already an improvement, but is there a way to put .pnpm
outside?
At the moment my Gitlab runner deletes node_modules
and the containing .pnpm
directory every pipeline. In that case it would have a global project node_modules directory I could keep over many pipelines. Thank you!
The node_modules/.pnpm
directory is called the virtual store directory. It is possible to change its location by setting the virtual-store-dir setting.
Files inside the virtual store directory are just hard links to the content-addressable store. I don't think you need to cache the contents of this directory. You need to cache the global store (the content-addressable store) instead. The global store is located at ~/.pnpm-store
by default. Its location can be changed via the store-dir setting.