Node.js·

Debugging Local Packages Made Easy with pnpm

Debug your local Node.js packages like a pro (and with less pain) using pnpm link.
A Developer looking at a monitor trying to debug code

Debugging Local Packages with pnpm link

If 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.

Meet the Cast

Picture this:

  • cool-package/: An open-source package you're working to contribute to because you're trying to fix a bug.
  • my-app/: The app that uses that package.
    

Your my-app/package.json might look like this:

    

But you want to test changes in @cool/package without publishing it every time. Here’s how to use pnpm link.

The Two-Step Process

  1. Link the package globally:
        
  2. Link it into your app:
        

    Now, your app uses your local version.

Debugging

  • Edit code in @cool/package.
  • Run or debug my-app.
  • If you need to build your library, run your build command.

To go back to the registry version:

  1. In my-app:
        
  2. In @cool/package:
        

Summary

pnpm link is a useful tool for local package development. It makes stepping into the code with breakpoints and debugging a breeze. See the PNPM docs on link for more details.