
This handles the surprisingly fiddly task of wiring up dependencies between packages in a monorepo, whether you're using npm, yarn, pnpm, or bun. It knows when to use workspace protocols versus let the package manager auto-symlink, and critically, it recognizes when "cannot find module" errors mean you need proper workspace linking instead of tsconfig path hacks. The workflow is straightforward: detect your package manager from lockfiles, identify which package needs which dependency, run the right command with the right flags. Honestly, the main value is not having to remember whether your setup wants `--filter`, `--workspace`, or just a plain add from the right directory.
$ npx -y skills add nrwl/nx-ai-agents-config --skill link-workspace-packages --agent claude-codeInstalls into .claude/skills of the current project.
Add dependencies between packages in a monorepo. All package managers support workspaces but with different syntax.
Check whether there's a packageManager field in the root-level package.json.
Alternatively check lockfile in repo root:
pnpm-lock.yaml → pnpmyarn.lock → yarnbun.lock / bun.lockb → bunpackage-lock.json → npmnode_modules/Uses workspace: protocol - symlinks only created when explicitly declared.
# From consumer directory
pnpm add @org/ui --workspace
# Or with --filter from anywhere
pnpm add @org/ui --filter @org/app --workspace
Result in package.json:
{ "dependencies": { "@org/ui": "workspace:*" } }
Also uses workspace: protocol.
yarn workspace @org/app add @org/ui
Result in package.json:
{ "dependencies": { "@org/ui": "workspace:^" } }
No workspace: protocol. npm auto-symlinks workspace packages.
npm install @org/ui --workspace @org/app
Result in package.json:
{ "dependencies": { "@org/ui": "*" } }
npm resolves to local workspace automatically during install.
Supports workspace: protocol (pnpm-compatible).
cd packages/app && bun add @org/ui
Result in package.json:
{ "dependencies": { "@org/ui": "workspace:*" } }
Example 1: pnpm - link ui lib to app
pnpm add @org/ui --filter @org/app --workspace
Example 2: npm - link multiple packages
npm install @org/data-access @org/ui --workspace @org/dashboard
Example 3: Debug "Cannot find module"
package.jsonpnpm install, npm install, etc.)<consumer>/node_modules/@org/<package>node_modulesnode_modules)package.json should have "private": true to prevent accidental publishSponsors