versioned_docs_archived/version-8.x/motivation.md
When using npm, if you have 100 projects using a dependency, you will have 100 copies of that dependency saved on disk. With pnpm, the dependency will be stored in a content-addressable store, so:
pnpm update will only add 1
new file to the store, instead of cloning the entire dependency just for the
singular change.As a result, you save a lot of space on your disk proportional to the number of projects and dependencies, and you have a lot faster installations!
pnpm perfoms installation in three stages:
node_modules directory structure is calculated based on the dependencies.node_modules.This approach is significantly faster than the traditional three-stage installation process of resolving, fetching, and writing all dependencies to node_modules.
When installing dependencies with npm or Yarn Classic, all packages are hoisted to the root of the modules directory. As a result, source code has access to dependencies that are not added as dependencies to the project.
By default, pnpm uses symlinks to add only the direct dependencies of the project into the root of the modules directory.
If you'd like more details about the unique node_modules structure that pnpm
creates and why it works fine with the Node.js ecosystem, read:
:::tip
If your tooling doesn't work well with symlinks, you may still use pnpm and set the node-linker setting to hoisted. This will instruct pnpm to create a node_modules directory that is similar to those created by npm and Yarn Classic.
:::