Search code examples
pnpm

How do I run a build for a single workspace using pnpm?


I am trying to use a repo that uses pnpm. I have used workspaces before on npm and yarn, but am not familiar with pnpm.

The repo organises it's workspaces two levels beneath packages, ie in this case I want to run the build script on the package in packages/starter/example

Reading the pnpm docs, I believe this should be:

pnpm --filter packages/starter/example run build

Which fails with:

pnpm --filter packages/starter/example run build
No projects matched the filters in "/home/me/myproject"

But I can see the directory is correct:

$ ls packages/starter/example/
CHANGELOG.md  LICENSE  README.md  next-env.d.ts  next.config.js  node_modules  package.json  public  src  tsconfig.json

Solution

  • If you want to filter by path, you need to either prefix the path with ./:

    pnpm --filter ./packages/starter/example run build
    

    or place it inside {}:

    pnpm --filter "{packages/starter/example}" run build