npm link: Developing packages w/o frequently bump

npm link is a very useful command when developing a package.
Suppose I have a project ~/project/mdserver, and a npm package ~/project/serve-markdown.
The obvious way to update the package version in mdserver is:

  • cd ~/project/serve-markdown, change the package and npm publish
  • cd ~/project/mdserver && npm install

Above way makes sense in most time, but it’s painful when the serve-markdown involves rapidly. You have to bump version frequently. In this situation, npm link!

  1. npm link in the package folder ~/project/serve-markdown. The command will create a global-installed symbolic link from prefix/serve-markdown to the current folder
  2. In the ~/project/mdserver dir, npm link serve-markdown will create a symbolic link from local node_modules folder to the global symlink

You can shortcut the two steps with one command:

npm link ../serve-markdown
in ~/project/mdserver directory.

Enjoy npm!


comments powered by Disqus