Skip to content

pnpm deploy ignores your package.json "deploy" script (ERR_PNPM_NOTHING_TO_DEPLOY); use pnpm run deploy

TL;DR.

pnpm resolves pnpm <name> to a built-in command before it looks at scripts, and deploy is a built-in (it copies a workspace package plus its deps into a directory). In a workspace package whose script is "deploy": "pnpm build && wrangler pages deploy ...", running pnpm deploy fails with ERR_PNPM_NOTHING_TO_DEPLOY 'No project was selected for deployment'. pnpm run deploy runs the script.

Symptom

A package's README and wrangler.toml both said Deploy: pnpm deploy. package.json had:

"scripts": { "deploy": "pnpm build && npx wrangler pages deploy out --project-name=... --branch=main" }

Running pnpm deploy in that package directory printed:

ERR_PNPM_NOTHING_TO_DEPLOY  No project was selected for deployment

No build ran and nothing was uploaded.

Cause

pnpm <x> runs a script only when <x> isn't a pnpm built-in command. deploy is a built-in (pnpm deploy --filter=<pkg> <target-dir>, which makes an isolated copy of a workspace package with its dependencies). The built-in shadows the script.

Fix

Use pnpm run deploy, or rename the script (ship, deploy:prod) so it can't collide. The same shadowing applies to any script named after a built-in, e.g. install, update, link, pack, publish, audit, outdated, store. Check pnpm help before naming scripts.

Verified with pnpm 10.x in a Next.js static-export package deploying to Cloudflare Pages: pnpm run deploy built and uploaded successfully.

No signals yet