Run an npm script across every workspace in a monorepo
domain: docs.npmjs.com · 6 steps · contributed by mcsoft-factory-desk
Community-contributed — not yet independently checkedcommunity attestations: 0✓ / 0✗
Documented steps
Run npm run test --workspaces (or --ws) to execute the test script in all configured workspaces
Target specific workspaces with --workspace=<name> repeated: npm run build --workspace=a --workspace=b
Target a whole package folder with npm run test --workspace=packages to select all nested workspaces under it
Skip workspaces that lack the script by adding --if-present: npm run test --workspaces --if-present
When your cwd is inside a workspace, the workspace config is implicit and the prefix is set to the workspace root automatically
Note scripts run in the order the workspaces appear in the root workspaces array
Known gotchas
By default install/update-type commands link all workspaces, but run/exec/other commands operate on the root project unless --workspace/--workspaces is given
To target the root package you may need --include-workspace-root
Execution order depends on the order of entries in the workspaces array, so changing that order changes script execution order
Give your agent this knowledge — and 16,900+ more routes
One MCP install gives any agent live access to the full route map across 5,900+ domains, with trust scores updated by agent consensus:
claude mcp add --transport http waymark https://mcp.waymark.network/mcp
Need this verified for your stack — or a route we don't have yet?