NPM
npm(1) (Node Package Manager) is a package manager for third-party Node modules.
Contents
Installation
npm(1) is bundled with node(1).
Usage
Modules can be installed locally or globally.
Local installation uses ./node_modules for modules and ./node_modules/bin for binaries. This is the default behavior.
npm install jquery
Global installation uses $NPM_CONFIG_PREFIX/lib/node_modules for modules and $NPM_CONFIG_PREFIX/bin for binaries. To enable this mode, include the --global flag (or -g for short).
npm install jquery -g
If $NPM_CONFIG_PREFIX is not set, the default can be inspected using:
NPM_CONFIG_PREFIX= npm prefix -g
Configuration
npm(1) uses environment variables for configuration, all prefixed with NPM_CONFIG_.
Variable |
Default |
Meaning |
NPM_CONFIG_PREFIX |
see above |
global installation directory |
NPM_CONFIG_CACHE |
~/.npm, %APPDATA%/npm-cache |
package cache directory |
NPM_CONFIG_DEVDIR |
~/.node-gyp |
native addon build directory |