
pnpm linkIf you’re tired of copy-pasting your local library into your app or publishing endless pre-release versions just to test a small change, there’s a better way.
pnpm link lets you connect your local package to your app, so you can debug and test changes without extra hassle.
Picture this:
cool-package/
├── src/
│ └── index.js
└── package.json
my-app/
├── src/
│ └── main.js
└── package.json
Your my-app/package.json might look like this:
{
"name": "my-app",
"version": "1.0.0",
"dependencies": {
"@cool/package": "1.0.0"
}
}
But you want to test changes in @cool/package without publishing it every time. Here’s how to use pnpm link.
cd @cool/package
pnpm link --global
cd ../my-app
pnpm link --global @cool/package
Now, your app uses your local version.
@cool/package.my-app.To go back to the registry version:
my-app:
pnpm unlink --global @cool/package
pnpm install --force
@cool/package:
pnpm unlink --global
pnpm link is a useful tool for local package development. Its makes stepping into the code with breakpoints and debugging a breeze. PNPM docs on link for more details.