DEV Community

Discussion on: The node_modules problem

Collapse
 
zkochan profile image
Zoltan Kochan • Edited

pnpm was created to solve this issue and is actively maintained since 2016.

This is how pnpm solves the issue:

  • one version of a package is only ever saved once on a disk in a global store
  • dependencies are imported to node_modules using hard links. So physically files of the package are the same in the global store and in every node_modules
  • symlinks are created inside node_modules to create a nested structure (more about it here

pnpm's solution is battle tested and does not hook into Node's module resolution algorithm, so it is backward compatible.

Indeed, there are new concepts like Yarn Plug'n'Play and Tink. However, they hook into Node's resolution algorithm. They might change the way we use JavaScript but that will be a long process. pnpm works now.