When developing a local Node module, we might want to point another project’s package.json at the local module. Here’s how you do that.

First, change directory to your local module and run npm link:

cd ~/code/my-module
npm link

This creates a global symlink pointing at your module:

npm ls -g --depth=0 --link
/opt/homebrew/lib
└── my-module@1.0.0 -> ./../../../Users/jake/code/my-module

Then, change directory into the place you want to install the module and link the package:

cd ~/code/my-consumer
npm link my-module

You’ll see it installed as a dependency, and as a symlink:

ls -al node_modules
my-module -> ../my-module

Now when we change and compile our module code, our consumer application will run it.

See man npm-link for more info.