This work-flow exists as a msu module - submarine

We all know how to install node modules globally:

⇒ npm install simple-argparse --global

For most people , this works! And there are those (me included) that hate that they usually have to use sudo to install a node module globally. And would really like a more customizable work-flow that just works without a lot of effort.

my work-flow

I install my node modules in ${HOME}/node_modules. Even without creating symbolic links, node can find these modules. I refer to them as globally-installed from here-on. Installing them is easy.

⇒ npm.g express grunt grunt-eslint

Some node modules come with executables! Just add ${HOME}/node_modules/.bin to your ${PATH}. In your ${HOME}/.bashrc, you can add this line:

export PATH=$HOME/node_modules/.bin:$PATH

For tools, such as grunt, it requires that the grunt tasks’ modules be in the ${PWD}/node_modules. Installing them every time sucks for me (am mostly using a capped network-bandwidth modem). Therefore I prefer creating symbolic links to my globally-installed node modules.

⇒ npm.ln grunt grunt-eslint

When moving between computers, I would like to ensure that I use the same globally-installed modules. In a perfect world I would move around with a 1TB hard drive but that is just tiring. I track my globally-installed node modules in ${HOME}/.node_modules. If you could use Dropbox (with mackup), you can easily synchronize that single file between your computers. To restore them in you new computer, you would:

⇒ npm.grestore


This primitive work-flow has allowed me to defer network operations while allowing rapid development!

I have composed this work-flow into commands that you can also start using. See submarine.

How is your work-flow?