NPM Tips and Tricks

Tips

NPM Link can be useful for cases where you are working on an NPM module and need to test the changes in another NPM module.

(see: NPM link )

Link the module you are developing globally on your system.

# run from the directory of the module you are developing in
# depending on your system, you may need to use sudo
npm link 
 
 
Add your linked module to the module you want to test in.
# run from the root directory for the module you want to test the developed module with
# <module-name> should be replaced by the name of the module you want to link in, this is derived from the name in its package.json file.
npm link <module-name>
 
When you no longer require the local link (e.g. finished testing ), remove the links to clean up the test settings.
# run from the directory of the module you are developing.
# depending on your system, you may need to use sudo
npm unlink
 
# in the root directory for the module you tested the developed module with
# <module-name> should be replaced by the name of the module you linked in, this is derived from the name in its package.json file.
npm unlink <module-name>

# run the install again to ensure that all the dependencies are properly installed
npm install