0

What is faster, have the modules of a node_modules folder saved in pnpm and use the package.json to install it with the pnpm or compress a node_modules folder in a rar file to extract in our project whenever we need to?

vitorfigm
  • 13
  • 1
  • 1
    Use a package manager to manage your packages. I would not convolute the process for the sake of some potential gain in speed. For example, pnpm caches files locally and symlinks them. If the cache is already primed then pnpm could install in less than a second. – Ryan Wheale Dec 23 '20 at 23:14

1 Answers1

0

Packing node_modules to an archive is not a good approach. It might even be slower as pnpm is verifying the contents of node_modules. When pnpm will detect that the files inside node_modules are not linked from the content-addressable store, it might remove them, fetch packages and relink them from the store.

If you really need to commit your dependencies, you can set a custom store location by setting store-dir. If you create a .npmrc file with this content: store-dir=pnpm-store, then pnpm will create the store in the root of your project. You can commit that store to the repository.

Alternatively, you can use Yarn v2. It uses Plug'n'Play by default and writes all dependencies into zip files. But as of now, Plug'n'Play still has issues with some stacks.

Zoltan Kochan
  • 5,180
  • 29
  • 38