### Setup pnpm with npx and @pnpm/exe Source: https://pnpm.io/installation Uses npx to run the setup command with @pnpm/exe, which is packaged with Node.js and can run on systems without Node.js installed. ```bash npx pnpm@latest-11 dlx @pnpm/exe@latest-11 setup ``` -------------------------------- ### Install pnpm Dependencies in Worktrees Source: https://pnpm.io/git-worktrees Run `pnpm install` in each worktree after enabling the global virtual store. The first install populates the global store, subsequent installs are fast. ```bash cd main && pnpm install cd ../feature-auth && pnpm install cd ../fix-api && pnpm install ``` -------------------------------- ### Specify a package to install with --package Source: https://pnpm.io/cli/pnx Installs a specified package before running the command, allowing for version specification. ```shell pnx --package=@pnpm/meta-updater meta-updater --help ``` ```shell pnx --package=@pnpm/meta-updater@0 meta-updater --help ``` -------------------------------- ### Publishing and Installing with a Specific Tag Source: https://pnpm.io/cli/publish Demonstrates how to publish a package with a custom tag (e.g., 'next') and how to install a package using that specific tag. ```bash # inside the foo package directory pnpm publish --tag next ``` ```bash # in a project where you want to use the next version of foo pnpm add foo@next ``` -------------------------------- ### Install Packages from Local File System Source: https://pnpm.io/package-sources Install packages directly from a local tarball file or a local directory. Installing from a directory creates a symlink, similar to 'pnpm link'. ```bash pnpm add ./package.tar.gz ``` ```bash pnpm add ./some-directory ``` -------------------------------- ### Install multiple packages with --package Source: https://pnpm.io/cli/pnx Provides multiple `--package` flags to install several packages before command execution. ```shell pnx --package=yo --package=generator-webapp yo webapp --skip-install ``` -------------------------------- ### Mix comma-separated and space-separated global package installations with pnpm Source: https://pnpm.io/global-packages This command demonstrates mixing installation types, bundling `eslint` and `prettier` into one isolated install while installing `typescript` separately. ```bash pnpm add -g eslint,prettier typescript ``` -------------------------------- ### Retrieve Values with pnpm pkg get Source: https://pnpm.io/cli/pkg Examples of using `pnpm pkg get` to retrieve specific fields or the full manifest from `package.json`. ```bash pnpm pkg get name pnpm pkg get name version pnpm pkg get scripts.test ``` -------------------------------- ### Install Bun globally with pnpm Source: https://pnpm.io/cli/runtime Installs the latest version of Bun globally using the `pnpm runtime set` command. ```bash pnpm runtime set bun latest -g ``` -------------------------------- ### Install prerelease Node.js versions globally with pnpm Source: https://pnpm.io/cli/runtime Demonstrates installing various prerelease versions of Node.js, including nightly builds, release candidates, and specific RC versions, all globally. ```bash pnpm runtime set node nightly -g ``` ```bash pnpm runtime set node rc -g ``` ```bash pnpm runtime set node rc/22 -g ``` ```bash pnpm runtime set node 22.0.0-rc.4 -g ``` -------------------------------- ### Install a single global package with pnpm Source: https://pnpm.io/global-packages Use this command to install a global CLI tool or utility system-wide. ```bash pnpm add -g ``` -------------------------------- ### Install Deno globally with pnpm Source: https://pnpm.io/cli/runtime Installs a specific major version of Deno globally using the `pnpm runtime set` command. ```bash pnpm runtime set deno 2 -g ``` -------------------------------- ### Install Node.js LTS by codename with pnpm env use Source: https://pnpm.io/cli/env Installs a specific LTS version of Node.js using its codename globally. ```bash pnpm env use --global argon ``` -------------------------------- ### Install with frozen store, offline, and frozen lockfile Source: https://pnpm.io/settings Use this command to perform an installation against a read-only, fully-populated package store, ensuring no modifications are made to the store or lockfile. ```shell pnpm install --frozen-store --offline --frozen-lockfile ``` -------------------------------- ### Install Package Globally with pnpm Source: https://pnpm.io/cli/add Use this command to install a package globally, making it available system-wide. ```bash pnpm add -g sax ``` -------------------------------- ### Install Multiple Global Packages with pnpm Source: https://pnpm.io/cli/add Use this command to install multiple packages globally into a single isolated install by providing them as a comma-separated list. ```bash pnpm add -g eslint,prettier ``` -------------------------------- ### Install pnpm on Windows with PowerShell Source: https://pnpm.io/installation Uses PowerShell to download and execute the pnpm installation script. Windows Defender may block the executable; npm or Corepack installation is recommended as an alternative. ```powershell Invoke-WebRequest https://get.pnpm.io/install.ps1 -UseBasicParsing | Invoke-Expression ``` -------------------------------- ### Install latest Node.js version with pnpm env use Source: https://pnpm.io/cli/env Installs the most recent stable version of Node.js globally. ```bash pnpm env use --global latest ``` -------------------------------- ### Set a pnpm runtime Source: https://pnpm.io/cli/runtime Installs the specified version of a runtime, such as Node.js, Deno, or Bun. The `-g` flag installs it globally. ```bash pnpm runtime set [-g] ``` -------------------------------- ### Demonstrate isolated global installations with pnpm Source: https://pnpm.io/global-packages Running these commands sequentially creates distinct isolated installations for each package, ensuring they do not interfere with each other's dependencies. ```bash pnpm add -g typescript ``` ```bash pnpm add -g prettier ``` -------------------------------- ### pnpm search usage examples Source: https://pnpm.io/cli/search Examples of searching for packages by keywords, including multi-word searches and scoped packages. ```bash pnpm search webpack plugin ``` ```bash pnpm search @types/node ``` -------------------------------- ### pnpm install Command Options Source: https://pnpm.io/cli/install Various options for the `pnpm install` command to control dependency installation behavior, including offline mode, lockfile management, and dry runs. ```shell pnpm i --offline ``` ```shell pnpm i --frozen-lockfile ``` ```shell pnpm i --lockfile-only ``` ```shell pnpm i --dry-run ``` -------------------------------- ### Install latest Node.js globally with pnpm Source: https://pnpm.io/cli/runtime Installs the most recent stable version of Node.js globally. ```bash pnpm runtime set node latest -g ``` -------------------------------- ### List locally installed Node.js versions with pnpm env list Source: https://pnpm.io/cli/env Displays a list of Node.js versions currently installed on the local system. ```bash pnpm env list ``` -------------------------------- ### pnpm version usage examples Source: https://pnpm.io/cli/version Common usage examples demonstrating version bumping with different strategies and options. ```bash pnpm version patch pnpm version minor pnpm version major pnpm version 2.0.0 pnpm version prerelease --preid beta ``` -------------------------------- ### Install LTS Node.js with pnpm env use Source: https://pnpm.io/cli/env Installs the latest Long Term Support (LTS) version of Node.js globally. ```bash pnpm env use --global lts ``` -------------------------------- ### pnpm set-script Usage Examples Source: https://pnpm.io/cli/set-script These examples demonstrate how to add common development scripts like `test`, `build`, and `lint` using `pnpm set-script` and its alias `pnpm ss`. ```bash pnpm set-script test "vitest run" pnpm set-script build "tsc -p ." pnpm ss lint "eslint ." ``` -------------------------------- ### Example pnpm-exec-summary.json file Source: https://pnpm.io/cli/run An example of the `pnpm-exec-summary.json` file generated when the `--report-summary` option is used, showing the execution status and duration for projects. ```json { "executionStatus": { "/Users/zoltan/src/pnpm/pnpm/cli/command": { "status": "passed", "duration": 1861.143042 }, "/Users/zoltan/src/pnpm/pnpm/cli/common-cli-options-help": { "status": "passed", "duration": 1865.914958 } } } ``` -------------------------------- ### Install specific Node.js version with pnpm env use Source: https://pnpm.io/cli/env Installs a specific major version of Node.js globally. ```bash pnpm env use --global 16 ``` -------------------------------- ### Run with Current pnpm Version Source: https://pnpm.io/cli/with Executes the `install` command using the currently globally installed pnpm version, ignoring any version pinned in the project's manifest. ```bash pnpm with current install ``` -------------------------------- ### Install prerelease Node.js versions with pnpm env use Source: https://pnpm.io/cli/env Installs various prerelease versions of Node.js globally, such as nightly builds, release candidates, or specific RC versions. ```bash pnpm env use --global nightly ``` ```bash pnpm env use --global rc ``` ```bash pnpm env use --global 16.0.0-rc.0 ``` ```bash pnpm env use --global rc/14 ``` -------------------------------- ### Install Package from 'next' Tag with pnpm Source: https://pnpm.io/cli/add Use this command to install a package from a specific npm tag, such as the `next` release channel. ```bash pnpm add sax@next ``` -------------------------------- ### Install Packages from Git Repository by Reference Source: https://pnpm.io/package-sources Install packages from a hosted Git provider by specifying a remote URL or a shorthand. You can target the latest commit, a specific commit hash, branch, or tag. ```bash pnpm add ``` ```bash pnpm add kevva/is-positive ``` ```bash pnpm add kevva/is-positive#97edff6f525f192a3f83cea1944765f769ae2678 ``` ```bash pnpm add kevva/is-positive#master ``` ```bash pnpm add zkochan/is-negative#heads/canary ``` ```bash pnpm add zkochan/is-negative#2.0.1 ``` ```bash pnpm add andreineculau/npm-publish-git#v0.0.7 ``` -------------------------------- ### Install Package from a Custom Catalog Entry Source: https://pnpm.io/config-dependencies After defining a catalog entry via a config dependency, use `pnpm add` with the `catalog:` prefix to install packages from that custom catalog. ```bash pnpm add is-odd@catalog: ``` -------------------------------- ### Install Node.js v22 globally with pnpm Source: https://pnpm.io/cli/runtime Installs a specific major version of Node.js globally using the `pnpm runtime set` command. ```bash pnpm runtime set node 22 -g ``` -------------------------------- ### Perform a clean install using pnpm ci Source: https://pnpm.io/cli/ci Use this command in CI/CD environments to perform a clean installation, ensuring reproducible builds by utilizing a frozen lockfile. ```bash pnpm ci ``` -------------------------------- ### Install from Git Repository using Hosting Provider Shorthand Source: https://pnpm.io/package-sources Utilize protocol shorthands like 'github:', 'bitbucket:', or 'gitlab:' for common Git hosting providers. If omitted, 'github:' is the default. ```bash pnpm add github:zkochan/is-negative ``` ```bash pnpm add bitbucket:pnpmjs/git-resolver ``` ```bash pnpm add gitlab:pnpm/git-resolver ``` -------------------------------- ### Install pnpm on POSIX systems with curl or wget Source: https://pnpm.io/installation Downloads and executes the pnpm installation script on Linux, macOS, and other POSIX systems. Not supported on Intel macOS; use npm, Corepack, or Homebrew instead. ```bash curl -fsSL https://get.pnpm.io/install.sh | sh - ``` ```bash wget -qO- https://get.pnpm.io/install.sh | sh - ``` -------------------------------- ### Install Packages from Remote Tarball URL Source: https://pnpm.io/package-sources Install a package from a remote tarball by providing a fetchable URL starting with 'http://' or 'https://'. This is considered an exotic source. ```bash pnpm add https://github.com/indexzero/forever/tarball/v0.5.6 ``` -------------------------------- ### Create React App with pnpm Source: https://pnpm.io/cli/create Initializes a new React project named 'my-app' using the `create-react-app` starter kit. ```bash pnpm create react-app my-app ``` -------------------------------- ### Modify Dependency Manifest with readPackage Hook Source: https://pnpm.io/pnpmfile Use this hook to mutate a dependency's `package.json` after parsing and prior to resolution. Changes affect what gets resolved in the lockfile and installed, but are not saved to the filesystem. Delete `pnpm-lock.yaml` if the dependency was already resolved. ```JavaScript function readPackage(pkg, context) { // Override the manifest of foo@1.x after downloading it from the registry if (pkg.name === 'foo' && pkg.version.startsWith('1.')) { // Replace bar@x.x.x with bar@2.0.0 pkg.dependencies = { ...pkg.dependencies, bar: '^2.0.0' } context.log('bar@1 => bar@2 in dependencies of foo') } // This will change any packages using baz@x.x.x to use baz@1.2.3 if (pkg.dependencies.baz) { pkg.dependencies.baz = '1.2.3'; } return pkg } export const hooks = { readPackage } ``` -------------------------------- ### Running pnpr with Custom Config and Cache Source: https://pnpm.io/pnpr/cli Illustrates how to start `pnpr` using a specific configuration file and a separate, ephemeral cache directory. ```bash pnpr -c ./pnpr.yaml --cache /mnt/ephemeral/pnpr-cache ``` -------------------------------- ### Install from Git Repository via Full URL Source: https://pnpm.io/package-sources Use a full Git URL (e.g., git+ssh or https) to explicitly specify the repository source. This is useful for alternative Git hosting or more precise control. ```bash pnpm add git+ssh://git@github.com:zkochan/is-negative.git#2.0.1 ``` ```bash pnpm add https://github.com/zkochan/is-negative.git#2.0.1 ``` -------------------------------- ### Verify pnpr installation version Source: https://pnpm.io/pnpr/installation Run this command to check the installed version of pnpr and confirm that the installation was successful. ```bash pnpr --version ``` -------------------------------- ### Set up a bare Git repository with multiple worktrees Source: https://pnpm.io/git-worktrees This sequence of commands initializes a bare Git repository and then adds 'main' and 'feature' worktrees, providing isolated working copies from a central bare repo. ```bash git clone --bare https://github.com/your-org/your-repo.git your-repo cd your-repo git worktree add ./main main git worktree add ./feature feat/something ``` -------------------------------- ### Examples of pnpm repo Usage Source: https://pnpm.io/cli/repo Demonstrates how to use `pnpm repo` to open the current project's repository, a single package's repository, or multiple package repositories. ```bash # Open the repo of the current project pnpm repo ``` ```bash # Open the repo of a package on the registry pnpm repo lodash ``` ```bash # Open multiple repos at once pnpm repo react react-dom ``` -------------------------------- ### Dockerfile: Install Node.js automatically via devEngines Source: https://pnpm.io/docker This Dockerfile leverages the `devEngines.runtime` configuration in `package.json` to automatically install Node.js during `pnpm install`, streamlining Node.js version management within the container. ```dockerfile FROM ghcr.io/pnpm/pnpm:11 WORKDIR /app COPY package.json pnpm-lock.yaml ./ RUN pnpm install --frozen-lockfile COPY . . CMD ["pnpm", "start"] ``` -------------------------------- ### Initialize Changesets Configuration Source: https://pnpm.io/using-changesets Run this command to generate the initial Changesets configuration files, including the .changeset directory. ```bash pnpm changeset init ``` -------------------------------- ### Install Specific Package Version with pnpm Source: https://pnpm.io/cli/add Use this command to install a package at a precise version number. ```bash pnpm add sax@3.0.0 ``` -------------------------------- ### Run pnpm server with R2 credentials and public URL Source: https://pnpm.io/pnpr/storage Set environment variables for R2 access keys and start the pnpm server, specifying the configuration file, listen address, and public URL. ```bash export AWS_ACCESS_KEY_ID="" export AWS_SECRET_ACCESS_KEY="" pnpr -c ./pnpr.yaml --listen 0.0.0.0:7677 --public-url https://registry.example.com ``` -------------------------------- ### Open documentation for the current project with pnpm Source: https://pnpm.io/cli/docs Run this command without arguments inside a package directory to open the documentation for the current project. ```bash pnpm docs ``` -------------------------------- ### Configuring Publish Options in `pnpm-workspace.yaml` Source: https://pnpm.io/cli/publish Demonstrates how to set `gitChecks` and `publishBranch` options directly within the `pnpm-workspace.yaml` file for workspace-wide configuration. ```yaml gitChecks: false publishBranch: production ``` -------------------------------- ### Basic Usage of pnpm with Source: https://pnpm.io/cli/with Shows the general syntax for using the `pnpm with` command to execute pnpm at a specific version or the current one. ```bash pnpm with ``` -------------------------------- ### Example `pnpm-publish-summary.json` File Source: https://pnpm.io/cli/publish Illustrates the structure of the `pnpm-publish-summary.json` file, which is generated when `--report-summary` is used, listing published packages. ```json { "publishedPackages": [ { "name": "foo", "version": "1.0.0" }, { "name": "bar", "version": "2.0.0" } ] } ``` -------------------------------- ### List Globally Installed pnpm Packages Source: https://pnpm.io/uninstall Use this command to view all packages installed globally by pnpm before proceeding with uninstallation. ```bash pnpm ls -g ``` -------------------------------- ### Run with pnpm Dist-Tag Source: https://pnpm.io/cli/with Executes the `install` command using the pnpm version associated with a specific dist-tag, such as 'next'. ```bash pnpm with next install ``` -------------------------------- ### Install LTS Node.js globally with pnpm Source: https://pnpm.io/cli/runtime Installs the current Long Term Support (LTS) version of Node.js globally. ```bash pnpm runtime set node lts -g ``` -------------------------------- ### Allow postinstall scripts with --allow-build Source: https://pnpm.io/cli/pnx Permits specified packages to run postinstall scripts during installation. ```shell pnx --allow-build=esbuild my-bundler bundle ``` -------------------------------- ### Install Node.js LTS by codename globally with pnpm Source: https://pnpm.io/cli/runtime Installs a specific LTS version of Node.js globally using its codename, such as 'argon'. ```bash pnpm runtime set node argon -g ``` -------------------------------- ### Install pnpr globally Source: https://pnpm.io/pnpr/installation Use pnpm to install the @pnpm/pnpr npm wrapper package globally. This requires Node.js 18 or newer. ```bash pnpm add -g @pnpm/pnpr ``` -------------------------------- ### Install multiple global packages individually with pnpm Source: https://pnpm.io/global-packages This command installs multiple packages, each into its own isolated environment, preventing dependency conflicts. ```bash pnpm add -g typescript prettier eslint ``` -------------------------------- ### Start the pnpr server Source: https://pnpm.io/pnpr/quick-start Run the pnpr server using the specified configuration file. The server will listen on `127.0.0.1:7677` by default. ```bash pnpr -c ./pnpr.yaml ``` -------------------------------- ### Open documentation for multiple packages with pnpm Source: https://pnpm.io/cli/docs This command opens the documentation for several specified packages simultaneously in your web browser. ```bash pnpm docs react react-dom ``` -------------------------------- ### Install Changesets CLI in pnpm Workspace Source: https://pnpm.io/using-changesets Install the Changesets CLI as a dev dependency in the root of your pnpm workspace to enable version management. ```bash pnpm add -Dw @changesets/cli ``` -------------------------------- ### Uninstall pnpm CLI Installed via npm Source: https://pnpm.io/uninstall Use this command to remove the pnpm CLI if it was originally installed globally using npm. ```bash npm rm -g pnpm ``` -------------------------------- ### Install dependencies using pnpm lockfile Source: https://pnpm.io/production Use this command in a production environment after committing the lockfile to ensure consistent dependency versions across environments. ```bash pnpm install ``` -------------------------------- ### Listing Globally Installed Packages with pnpm Source: https://pnpm.io/global-packages Commands to list globally installed pnpm packages, including options for machine-readable and parseable output. ```shell pnpm list -g ``` ```shell pnpm list -g --json # machine-readable ``` ```shell pnpm list -g --parseable # paths only ``` -------------------------------- ### Configure pnpm for AppVeyor CI Source: https://pnpm.io/continuous-integration Use this configuration in your `appveyor.yml` to install Node.js, enable Corepack, activate pnpm, and install project dependencies. ```yaml install: - ps: Install-Product node $env:nodejs_version - npm install --global corepack@latest - corepack enable - corepack prepare pnpm@latest-11 --activate - pnpm install ``` -------------------------------- ### Example pnpm Workspace Directory Structure Source: https://pnpm.io/workspaces Illustrates a common file structure for a pnpm monorepo, showing how multiple packages are organized within a `packages` directory. ```plaintext + packages + foo + bar ``` -------------------------------- ### Package.json with catalog protocol dependency Source: https://pnpm.io/catalogs Illustrates a `package.json` file using the `catalog:` protocol for a dependency. ```json { "name": "@example/components", "dependencies": { "react": "catalog:react18" } } ``` -------------------------------- ### Install pnpm plugin for TypeScript types fix Source: https://pnpm.io/typescript Install the `@pnpm/plugin-types-fixer` config dependency to automatically deal with `@types/` dependency issues in a pnpm workspace. ```bash pnpm add @pnpm/plugin-types-fixer --config ``` -------------------------------- ### Authenticate in GitHub Actions with setup-node Source: https://pnpm.io/blog/2026/06/11/env-variables-in-repository-npmrc Configure GitHub Actions to authenticate with a registry by using `actions/setup-node` and passing `NODE_AUTH_TOKEN` as an environment variable. ```yaml - uses: actions/setup-node@v4 with: node-version: 24 registry-url: https://registry.npmjs.org - run: pnpm install env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} ``` -------------------------------- ### pnpm deprecate Source: https://pnpm.io/cli/deprecate Set a deprecation message on a published package version. Consumers running `pnpm install` will see this message when the matching version is installed. ```APIDOC ## pnpm deprecate ### Description Set a deprecation message on a published package version. Consumers running `pnpm install` will see this message when the matching version is installed. ### Command `pnpm deprecate [@] ` ### Arguments - **pkg[@version-range]** (string) - Required - The package name, optionally with a version range, to deprecate. - **message** (string) - Required - The deprecation message to set. Use an empty string `""` to clear a deprecation message. ### Options - **--registry ** (string) - Optional - The registry to publish to. Defaults to the registry configured for the package. - **--otp ** (string) - Optional - When the registry requires two-factor authentication, supply the one-time password via this flag or the `PNPM_CONFIG_OTP` environment variable. ### Examples ``` pnpm deprecate foo@1.0.0 "Use foo@2 instead" pnpm deprecate "foo@<2" "Please upgrade to foo@2" pnpm deprecate foo "This package is no longer maintained" pnpm deprecate foo@1.0.0 "" ``` ``` -------------------------------- ### Install a pnpm Plugin as a Config Dependency Source: https://pnpm.io/config-dependencies Install a pnpm plugin, following the naming convention, as a config dependency to enable its hooks and dynamic configuration updates. ```bash pnpm add --config @myorg/pnpm-plugin-my-catalogs ``` -------------------------------- ### Install Subdirectory from Git Repository Source: https://pnpm.io/package-sources Install only a specific subdirectory from a Git-hosted monorepo using the 'path:' parameter. This is useful for extracting a single package from a larger repository. ```bash pnpm add RexSkz/test-git-subfolder-fetch#path:/packages/simple-react-app ``` -------------------------------- ### Run a package without installing Source: https://pnpm.io/cli/pnx Executes a package's default command binary directly from the registry. ```shell pnx create-vue my-app ```