17

I start using PNPM Workspaces, and I'm struggling in how to add dependencies to any specific workspace as I would do in yarn running:

yarn workspace <workspace_name> add <package_to_add>

Or even running scripts for specific packages as I would do in yarn like:

yarn workspace <workspace_name> run <script>

How is the PNPM community doing this? You really need to go to the workspace package.json file and add it manually?

Been a while searching for docs without success

Thanks!

Arnautg
  • 661
  • 6
  • 10

2 Answers2

22

So I found an answer and is using the --filter option.

i.e.

# Using the exact package name
pnpm add <package_to_add> --filter <workspace_name>
# Or using a pattern
pnpm add <package_to_add> --filter <prefix>/*

Same for run, etc...

Arnautg
  • 661
  • 6
  • 10
0

For me, I removed the pnpm-workspace.yaml from the root folder of my app and the error gone.

Mohsen
  • 4,000
  • 8
  • 42
  • 73
  • I had to remove it to get the deps to install correctly. I expect something is missing which prevents pnpm-workspace.yml from working correctly. Any idea what that may be? – aaronmbmorse Aug 13 '23 at 16:41