Using npm link to test a module locally

NicolasBrondinBernard

Author
@NicolasBrondinBernard

Discover how to use the `npm link` command to develop and test an NPM module locally without having to publish it every time you make a change.

Article published on 17/05/2026, last updated on 10/08/2026

When you're developing an NPM package, there's a problem that quickly becomes frustrating:

Every time you modify the module, you would normally have to:

  • publish a new version
  • reinstall the package in the test project
  • restart the application

Fortunately, npm link exists precisely to avoid this.

How it works

This command lets you create a symbolic link between a local package and another project.

In other words: your project directly uses the local source code of the module, as if it had been installed from NPM.

The process happens in two steps. First, in the NPM package folder:

npm link

This command registers the package globally on your machine.

Then, in the project that needs to use this package:

npm link nom-du-package

From that point on, the project's node_modules folder will point directly to your local module.

A symbolic link

The big advantage is that changes become almost instantaneous. You change code in your package… and your test project immediately uses the new version.

No more need to publish a 0.0.1-dev-test-42 version.

Under the hood, npm link uses the operating system's symbolic links (symlink).

A concrete example

Here's an example to clearly understand the steps to follow. You have two projects:

mon-package/
mon-app/

In mon-package:

npm link

Then in mon-app:

npm link mon-package

And there you go. Your application now directly uses the local version of the package.


Finished reading this article?
Our complete courses
Take it to the next level with our courses!

Complete courses, exercises and certificates to really learn programming!

4.8 average rating

Comments (0)

to leave a comment

No comments yet

Frequently asked questions covered in this article

how npm link works test npm package locally npm local package npm workspace vs npm link how to use npm link