Self-contained Node.js scripts

Deploying Node applications should be a straightforward task.
For some reasons, you can read here and there that additional dependencies need to be installed globally.

Which is generally very rarely needed.

tl;dr

You will learn how to create tidy one line Node.js installs and how to distribute complimentary tooling for advanced users and developers.

Global install

Global install of Node modules is designed for system-wide command-line applications.

If you request your users to install additional and global Node modules in order to use your app… well, it works but it is wrong. And please, don't make Soledad angry ;-)

It is wrong because it adds extraneous implicit steps in the install process. And worse, it exposes you to global version conflicts.
If a module asks for npm install -g browserify@1.0.0 and another one asks for npm install -g browserify@5.0.0, you are screwed in a way or another.

It is okay to install global modules for unique executables (like npm) or global wrappers (like grunt-cli or gulp-cli) if they are non-project specific.

So what if you want to provide executables to your standalone application? Like building, updating data from a registry or whatever? Well, you have two choices:

The trick is any npm command prefixes the $NODE_PATH variable for the duration of the command only (no global leak).
In other terms, Node will first look for local executables before looking for globally available ones.