💸Save up to $132K/month in CI costs!👉 Try Free
Skip to main content
← Back to workflows

How to Use the Setup pnpm GitHub Action

pnpm-action-setup -
GitHub Action
v4.0.0
917
Contributors
Contributor - KSXGitHubContributor - zkochanContributor - Jack-Works
Categories

Optimize Your CI/CD Pipeline

Get instant insights into your CI/CD performance and costs. Reduce build times by up to 45% and save on infrastructure costs.

45% Faster Builds
60% Cost Reduction
Usage
name: 'Usage of action-setup GitHub Action'
on:
push:
branches:
- main
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
with:
version: latest

action-setup logo

PnPM Setup

Install pnPm package manager


What is PnPM Setup?

The Setup pnpm GitHub Action installs the pnpm package manager, enabling efficient package management for JavaScript and TypeScript projects.

How to Install pnpm and a Few npm Packages

This example demonstrates how to set up pnpm and install a few npm packages.

- uses: pnpm/action-setup@v4
with:
version: 8
run_install: |
- recursive: true
args: [--frozen-lockfile, --strict-peer-dependencies]
- args: [--global, gulp, prettier, typescript]

How to Use Cache to Reduce Installation Time

This example demonstrates how to cache pnpm store to reduce installation time.

- uses: pnpm/action-setup@v4
name: Install pnpm
with:
version: 8
run_install: false

- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV

- uses: actions/cache@v4
name: Setup pnpm cache
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-

- name: Install dependencies
run: pnpm install

How to Specify pnpm Version

Version of pnpm to install. This is optional if the packageManager field is present in package.json. Supports npm versioning scheme.

with:
version: 6.24.1

How to Specify Destination

Where to store pnpm files.

with:
dest: ~/.pnpm

How to Run pnpm Install

If specified, runs pnpm install. Can be true, false, or a YAML string representation of an object or array.

with:
run_install: true

How to Use Recursive Install

Whether to use pnpm recursive install.

with:
run_install:
recursive: true

How to Specify Working Directory for Install

Working directory when running pnpm [recursive] install.

with:
run_install:
cwd: subdirectory/

How to Add Additional Arguments for Install

Additional arguments after pnpm [recursive] install.

with:
run_install:
args: [--frozen-lockfile, --strict-peer-dependencies]

How to Specify package.json File Path

File path to the package.json to read "packageManager" configuration.

with:
package_json_file: path/to/package.json

How to Enable Standalone Mode

When set to true, @pnpm/exe will be installed, enabling using pnpm without Node.js.

with:
standalone: true