Skip to content

How does pnpm work? #5

@anonrig

Description

@anonrig

A small overview of how I interpret pnpm.

Disclaimer: This is a living document and might be wrong. Please comment on this issue and let's document it together.

Prepare environment

  1. Create node_modules/.pacquet folder which is the virtual store path.

Add package

For a given package (example fastify) and a version (v1.0.0):

Variables:

  • $STORE=node_modules/.pacquet
  • $PKG=fastify
  • $VERSION=1.0.0

Steps:

  • Install package to $STORE/$PKG@$VERSION/node_modules/$PKG
  • If there is a dependency of this package:
    1. Create an empty folder at path $STORE/fastify@$VERSION/node_modules/$PKG/node_modules
  • Symlink node_modules/$PKG to STORE/$PKG@$VERSION/node_modules/$PKG
  • For every dependency of $PKG:
    1. Set $PKG to dependency name
    2. Set $VERSION to `dependency version
    3. Run installation steps from the beginning
  • Update package.json with appropriate version
    1. If package.json is not defined, create a file with only dependencies
  • Update/create shrink file with appropriate ranges

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions