Linking Local Packages
What you'll learn: How workspace packages in a monorepo can depend on each other locally, without needing to publish them to a registry first.
The Core Idea
In a monorepo with workspaces, you often have multiple packages that depend on each other—like a shared UI library used by several apps. Instead of publishing each change to npm and re-installing, workspace linking lets packages reference each other directly from the filesystem. When you modify one package, dependent packages see changes immediately.
Think of it like having multiple rooms in the same house connected by doors, rather than having to step outside and walk around the block every time you need something from another room.
How It Works
When you list a workspace package in another workspace package's dependencies, your package manager (npm, Yarn, or pnpm) creates a symlink or uses special resolution logic to point directly to the local source code instead of fetching from the registry.
For example, if your monorepo has packages/ui-lib and apps/web-app, and web-app's package.json lists:
{
"dependencies": {
"ui-lib": "workspace:*"
}
}
…the package manager links node_modules/ui-lib in web-app directly to packages/ui-lib. Changes to ui-lib are instantly available to web-app—no reinstall needed.
Why This Matters
Linking enables rapid iteration. You can develop multiple interconnected packages simultaneously, testing integration in real-time. This is the foundation of efficient monorepo workflows—tight collaboration between packages without the friction of publish-install cycles.
Key Takeaway:
Workspace linking lets monorepo packages reference each other locally via symlinks or special resolution, enabling instant cross-package updates without publishing intermediates.