npm link Explained
What npm link does, with an example.
Published November 11, 2026
npm link creates a symlink so you can develop a package locally and use it in another project without publishing. Changes appear immediately.
How it works
Run npm link in the package folder to register it globally, then npm link <name> in the consumer project.
Unlink when finished to avoid confusion.
Try it
cd my-lib && npm link
cd ../my-app && npm link my-lib
my-app/node_modules/my-lib -> ../../my-lib
Practical examples
Link a library
cd my-lib && npm link
cd ../my-app && npm link my-libUnlink
npm unlink my-lib
cd ../my-lib && npm unlinkAlternative: file dependency
{ "dependencies": { "my-lib": "file:../my-lib" } }Workspaces alternative
npm init -w packages/my-libCommon mistakes
- Duplicate React/peer copies from linked packages.
- Forgetting to rebuild the linked package.
- Leaving links in place.
Key takeaways
- npm link creates a symlink so you can develop a package locally and use it in another project without publishing.
- Run npm help <command> for every option.
- Commit package-lock.json.
FAQ
Alternatives?
npm workspaces or file: dependencies.
Does this work with yarn or pnpm?
They have equivalents with similar commands.