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

1

12

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.

Satterlee answered 9/6, 2022 at 6:42 Comment(0)
T
13

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
Twoseater answered 9/6, 2022 at 9:16 Comment(4)
--filter works, thanks! -F doesn't for some reason though.Satterlee
It's worth noting that the filter will looking for the "name" in the package's "package.json" file, not the name of the package directory.Onomastic
Would it work the same way as if I was in the particular package and run the pnpm add react from that folder?Rew
@Rew yes, it would be the sameTwoseater

© 2022 - 2024 — McMap. All rights reserved.