link-workspace-packages

Link workspace packages across npm, yarn, pnpm, and bun.

1|Updated Jul 15, 2024
One-click install
npx skills add https://github.com/EelcoLos/nx-tinkering --skill link-workspace-packages-eelcolos
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: link-workspace-packages
Source: https://github.com/EelcoLos/nx-tinkering/tree/main/.gemini/skills/link-workspace-packages
Command: npx skills add https://github.com/EelcoLos/nx-tinkering --skill link-workspace-packages-eelcolos

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Link workspace packages in a monorepo to wire up dependencies across npm, yarn, pnpm, and bun. It helps ensure you use the workspace workflow provided by your package manager rather than patching tsconfig paths or manual package.json edits.

Core Features & Use Cases

  • Detect the active workspace manager by inspecting root package.json or lockfiles.
  • Provide a clear workflow to link newly created packages or dependencies from a sibling package.
  • Help resolve common workspace-related errors such as cannot find module, failed to resolve import, or TS2307.
  • Demonstrate linking patterns for pnpm, yarn, npm, and bun in real projects.

Quick Start

From the consumer package directory, run the workspace add command for your package manager to wire the dependency on the provider package.

Frequently Asked Questions about link-workspace-packages

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I link workspace packages in a monorepo to fix module resolution errors?

To link workspace packages in a monorepo, run your package manager's workspace add command from the consumer package directory to wire dependencies on the provider package, resolving errors like cannot find module or TS2307.

Why do I get a TS2307 or cannot find module error when importing from a sibling package?

Errors like TS2307 or cannot find module occur because workspace dependencies are not linked. You must use your package manager's workspace commands to establish the actual link rather than patching tsconfig paths.

Can I use workspace linking with pnpm, yarn, npm, and bun monorepos?

Yes, workspace linking works across pnpm, yarn, npm, and bun. The process detects your active workspace manager by inspecting the root package.json or lockfiles and applies the correct linking patterns for that specific tool.

What is the best way to wire up newly created packages in a monorepo?

The best way to wire up newly created packages is using your package manager's native workspace workflow to add dependencies, which properly links the packages instead of relying on manual package.json edits or tsconfig path aliases.

Should I edit tsconfig paths to resolve imports between workspace packages?

No, you should not edit tsconfig paths to resolve imports between workspace packages. You should enforce using the package manager's workspace commands to fix actual linking instead of patching configurations or manually editing package.json.