npm link

Node.js package linking is a two-step process. First, npm link in a package folder will create a globally-installed symbolic link to the current folder. Next, in some other location (ie the plugin folder you are developing):

npm link your-package-name

will create a symlink from the local node_modules folder to the global symlink.

# Examples

Let's say we are working on a new plugin for redis. First we cd into the package directory, then create a global link, before moving into the directory where we have out wiki, and connecting our new plugin there (by creating a symlink) using npm link redis.

cd ~/projects/node-redis npm link cd ~/projects/node-bloggy npm link redis

Now, any changes to ~/projects/node-redis will be reflected in ~/projects/node-bloggy/node_modules/node-redis/. Note that the link should be to the package name, not the directory name for that package.

You may also shortcut the two steps in one. For example, to do the above use-case in a shorter way:

cd ~/projects/node-bloggy # go to main project npm link ../node-redis # link your dependency

Site Owned by: David Bovill