Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Next.js and React

The shell says pnpm: command not found

Errorpnpm: command not found

Short answer

The shell cannot find a pnpm executable on PATH. Either pnpm was never installed, it was installed but its folder is not on PATH yet, or you relied on Corepack, which Node.js no longer bundles from version 25. Check with which pnpm, then install pnpm, run pnpm setup, or install Corepack.

  • Applies to Node.js 22, Node.js 24, Node.js 25, macOS, Ubuntu 24.04
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Find out whether any pnpm is on PATH, and which Node.js you run. The answers split the three causes.

    which pnpm; echo "exit: $?"
    node --version
    echo "$PATH" | tr ':' '\n' | head -n 20
  2. 2Match what you see, then jump to its fix

    1. 1which pnpm prints nothing, and you have never run an installer on this machinepnpm was never installedFix
    2. 2The install finished without errors, but pnpm is still not found in the same terminalpnpm is installed, but its folder is not on PATHFix
    3. 3node --version is 25 or newer, and corepack enable fails or corepack is not foundYou relied on Corepack, which your Node.js does not includeFix

What does the error look like?

  • pnpm: command not found
  • npx next dev works, but pnpm dev or pnpm install is not found

Cause 1 of 3

pnpm was never installed

1Check

pnpm is a separate tool. A fresh machine or a new container has no pnpm until you install it.

command -v pnpm || echo 'pnpm not on PATH'

2Fix

Use the standalone installer, or npm if Node.js is already there. The npm global install needs Node.js 18 or newer.

# standalone script, no Node.js needed
curl -fsSL https://get.pnpm.io/install.sh | sh -

# or, with Node.js 18+
npm install -g pnpm@latest

3Verify

Open a new terminal and ask for the version.

pnpm --version

Confirmed by pnpm.io

Did this fix it?

Cause 2 of 3

pnpm is installed, but its folder is not on PATH

1Check

pnpm setup creates the pnpm home directory and adds it to PATH by updating your shell configuration file. If it cannot tell which shell file to change, it prints the PNPM_HOME and PATH lines for you to add by hand.

echo "$PNPM_HOME"

2Fix

Run the setup command, then open a new shell so the change is read.

pnpm setup
exec "$SHELL" -l

3Verify

pnpm resolves from any folder.

command -v pnpm

Confirmed by pnpm.io

Did this fix it?

Cause 3 of 3

You relied on Corepack, which your Node.js does not include

1Check

Corepack is distributed with Node.js from 14.19.0 up to, but not including, 25.0.0. corepack enable creates the pnpm and Yarn shims on your path.

command -v corepack; node --version

2Fix

On Node.js 25 and later, install Corepack with npm first, then enable the pnpm shim. Remove any global pnpm binary before this, as the Corepack readme advises.

npm install -g corepack
corepack enable pnpm

3Verify

The shim answers, and a project with a packageManager field gets the version it names.

pnpm --version

Confirmed by github.com

Did this fix it?

How do I stop it coming back?

  • Put the install step in your setup script or Dockerfile, not in someone's memory.
  • Pin the tool in package.json with the packageManager field so Corepack uses one version for everyone.
  • After any install that edits shell files, open a new terminal before testing.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Web apps

tsconfig rejects allowImportingTsExtensions

An error that allowImportingTsExtensions needs noEmit or emitDeclarationOnly

allowImportingTsExtensions lets files import each other with .ts or .tsx extensions, and TypeScript only allows it together with noEmit or emitDeclarationOnly.

2 causes, each with a fix

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.