npm
The npm is the package manager used by Node to distribute modules. The npm can be used to install, update, and manage modules. Package managers are popular in other languages such as Python. The npm automatically resolves and updates dependencies for a package and hence makes your life easy.
Installing packages
There are two ways to install npm packages: locally or globally. If you want to use the module's functionality only for a specific Node project, you can install it locally relative to the project, which is default behavior of npm install
. Alternatively, there are several modules that you can use as a command-line tool; in this case, you can install them globally:
npm install request
The install
directive with npm
will install a particular module—request
in this case. To confirm that npm install
worked correctly, check to see whether a node_modules
directory exists and verify that it contains a directory for the package(s) that you installed.
As you start adding modules to your project...