Luke Oliff.

TIL: Testing npm Packages Locally With npm link

·TIL·1 min read·Luke Oliff

Testing an npm package before publishing means using it in a real project. npm link connects them.

cd ~/projects/deepgram-sdk
npm link

cd ~/projects/demo-app
npm link @deepgram/sdk

The first command registers the SDK globally. The second creates a symlink in demo-apps node_modules pointing at your local SDK directory. Edit the SDK, save, and the demo app picks up the changes.

npm unlink @deepgram/sdk

Replaces the symlink with the real published package. Run npm install –force to clean up stale symlink state.

What if I want two linked packages?

Link each one separately. npm link resolves transitive dependencies through real node_modules lookups.

Does this work with npm workspaces?

Workspaces handle this better. Use npm link only for cross-repo testing.