Search code examples
pnpm

pnpm install a library inside micro frontend


I am using pnpm workspaces with turborepo, and I'm having issues installing packages.

I want to install a package only for a certain application/workspace, eg. portals/cashout

Whenever I do

pnpm install lodash

It would warn me that this would be global workspace, which is not what I need.

I need something like

pnpm install lodash --workspace=portals/cashout

Solution

  • You can use filtering

    To filter by path:

    pnpm add lodash --filter=./portals/cashout
    

    To filter by package name, you can specify the name of the package. For instance:

    pnpm add lodash --filter=cashout
    

    You can also just change the directory to portals/cashout and run installation there.