Overview
Use this Skill when an application imports a sibling package that exists in the repository but is not correctly declared as a dependency. Its starting point is the relationship between the consuming package and the providing package, rather than an editor-only path alias. A missing declaration and a missing build output require different fixes.
The source covers npm, pnpm, Yarn and Bun. It asks the agent to identify the repository’s package manager, select the consumer and use the corresponding workspace command. For example, its pnpm recipe targets the consumer with --filter and requires a local package with --workspace. The resulting manifest and lockfile changes still need review.
Verification depends on the install mode: Yarn Plug’n’Play can resolve packages through .pnp.cjs without node_modules. A missing symlink therefore does not establish failure. Test the affected import and its normal build or type check; package exports and generated artifacts can still cause errors after the dependency is correctly linked.
What to prepare
- The consumer and provider package names, their package.json files and the failing import.
- The root packageManager field, lockfile, workspace configuration and installed manager version.
What you get
- A dependency declaration in the correct consumer and the corresponding install state.
- An import/build check that distinguishes linking problems from export or artifact problems.
Suggested workflow
- Identify which package imports which local provider and confirm both belong to the workspace.
- Read the manager/version and select its workspace syntax; do not mix recipes from different managers.
- Apply the dependency change to the intended consumer and review manifest and lockfile differences.
- Verify resolution using the active linker, then run the affected project’s existing checks.
Limits and checks
- A similarly named registry package is not necessarily the local provider.
- Do not require node_modules when Yarn PnP is active.
- Check package exports and build outputs if linking succeeds but imports still fail.
- This is dependency wiring; nx-import moves code/history and nx-plugins adds Nx integrations.
Common questions
Does this Skill require Nx?
Its reviewed instructions use package-manager workspaces and do not declare Nx or an Nx MCP server as a prerequisite. A compatible coding agent and the repository context are still needed.
Is the copy in nrwl/nx a different capability?
At the two pinned revisions reviewed here, the Skill directories are identical. This page covers the nx-ai-agents-config distribution; choose the source already used by your setup rather than expecting a second capability.
Has the workflow been independently executed here?
No. This explanation is based on the pinned Skill and official package-manager documentation, not a test of your repository.
Install this skill
Use the Skills CLI to add this skill from its verified GitHub source.
npx skills add https://github.com/nrwl/nx-ai-agents-config --skill link-workspace-packagesSource information
- github.com/nrwl/nx-ai-agents-config/blob/13282936b5f6aa53e3d41ba589a4a2dc0d6f5786/skills/link-workspace-packages/SKILL.md
- github.com/nrwl/nx-ai-agents-config/blob/13282936b5f6aa53e3d41ba589a4a2dc0d6f5786/README.md
- github.com/nrwl/nx/tree/d976a693f12e81402bcbd53d4b04f91974650c04/.agents/skills/link-workspace-packages
- pnpm.io/cli/add
- yarnpkg.com/features/pnp
Rendered from the source repository. Headings, examples, code, tables, links, and referenced images are preserved.
Link Workspace Packages
Add dependencies between packages in a monorepo. All package managers support workspaces but with different syntax.
Detect Package Manager
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→ npm
Workflow
- Identify consumer package (the one importing)
- Identify provider package(s) (being imported)
- Add dependency using package manager's workspace syntax
- Verify symlinks created in consumer's
node_modules/
pnpm
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 --workspaceResult in package.json:
{ "dependencies": { "@org/ui": "workspace:*" } }yarn (v2+/berry)
Also uses workspace: protocol.
yarn workspace @org/app add @org/uiResult in package.json:
{ "dependencies": { "@org/ui": "workspace:^" } }npm
No workspace: protocol. npm auto-symlinks workspace packages.
npm install @org/ui --workspace @org/appResult in package.json:
{ "dependencies": { "@org/ui": "*" } }npm resolves to local workspace automatically during install.
bun
Supports workspace: protocol (pnpm-compatible).
cd packages/app && bun add @org/uiResult in package.json:
{ "dependencies": { "@org/ui": "workspace:*" } }Examples
Example 1: pnpm - link ui lib to app
pnpm add @org/ui --filter @org/app --workspaceExample 2: npm - link multiple packages
npm install @org/data-access @org/ui --workspace @org/dashboardExample 3: Debug "Cannot find module"
- Check if dependency is declared in consumer's
package.json - If not, add it using appropriate command above
- Run install (
pnpm install,npm install, etc.)
Notes
- Symlinks appear in
<consumer>/node_modules/@org/<package> - Hoisting differs by manager:
- npm/bun: hoist shared deps to root
node_modules - pnpm: no hoisting (strict isolation, prevents phantom deps)
- yarn berry: uses Plug'n'Play by default (no
node_modules) - Root
package.jsonshould have"private": trueto prevent accidental publish



