javascriptnode.jsmonorepopnpmpnpm-workspace

pnpm in monorepo - how to run a command only in a specific package?


Let's say I want to install a package in a specific package in my monorepo, how do I do this from root?

in npm, you can do this with something like this:

npm install react --workspace=a

I searched the docs and I can't find a way to do this in pnpm.


Solution

  • It is called "filtering" in pnpm docs (see it here).

    In this case, you would run:

    pnpm --filter=a add react
    

    or

    pnpm -F=a add react