node

node global and local installations

 
Type of node installation
In npm 1.0, there are two ways to install things:

    1.    globally —- This drops modules in {prefix}/lib/node_modules, and puts executable files in {prefix}/bin, where {prefix} is usually something like /usr/local. It also installs man pages in{prefix}/share/man, if they’re supplied.

npm install packagename -g

   2.    locally —- This installs your package in the current working directory. Node modules go in ./node_modules, executables go in./node_modules/.bin/, and man pages aren’t installed at all.

npm install packagename

WHICH TO CHOOSE
Whether to install a package globally or locally depends on the global config, which is aliased to the -g command line switch.
Just like how global variables are kind of gross, but also necessary in some cases, global packages are important, but best avoided if not needed.

In general, the rule of thumb is:
    1.    If you’re installing something that you want to use in your program, using require(‘whatever’), then install it locally, at the root of your project.
    2.    If you’re installing something that you want to use in your shell, on the command line or something, install it globally, so that its binaries end up in your PATH environment variable.

Source: http://blog.nodejs.org/2011/03/23/npm-1-0-global-vs-local-installation

Error: “ENOENT”

Meanings:
It’s an abbreviation of Error NO ENTry, and can actually be used for more than files/directories.
Cause:
No such file or directory. This is a “file doesn’t exist” error for ordinary files that are referenced in contexts where they are expected to already exist.
source