This post explains how to install node.js library or module. Two ways to do this : local install or globally install.


To do before

– know what node.js is (see blog post Comprendre node.js)
node.js installed (see blog post on Installer node.js sous Windows).


npm, what’s that ?

npm is the tool to install, remove, search or configure node.js packages.


Local install

In this way, a installed library can’t to be used by another project different as your own.
After module install, if you read inside your directory project, you can find a new directory called node_modules. This directory saves all installed modules used by your project only.

npm command to install node.js module :

npm install module_name

For example, library :

npm install


Globally install

Globally install enables to use node.js library from all projects. It’s not needed to install node.js module for all projects : one install is enough. By this whay, all modules are installed in a specific directory that you can specify.

npm install command for globally install :

npm -g install nom_module

For example, with library :

npm -g install

You can configure a specific directory modules installation with next command :

npm config set prefix path_to_directory_modules_installation

It’s easy, no ?

[important]Comments, improvement, idea : let me know. If this post has been helpful, make comments on your favorite social networks.[/important]