To learn more about a certain npm command
|
npm help <command>
Example:
npm help publish
|
Install module locally in a node_modules directory.
If the node_modules directory does not exist, it will be created.
|
npm install <module>
Example:
npm install underscore
Note:
If your project contains a package.json file, you install the project by using command:
npm install
|
Modules can also be installed globally.
In Windows Vista it is installed in directory:
C:\Users\<your_account>\AppData\Roaming\npm
|
npm install <module> -g
Example:
npm install underscore -g
|
Update modules
|
To update a module in your project "node_modules" folder to its latest version, type:
npm update <module>
Example:
npm update underscore
To update all modules in your project "node_modules" folder to its latest versions, type:
npm update
To update all global modules to its latest versions, type:
npm update -g
|
npm has a registry of all the modules you can install.
You can display the complete list or search for a particular word.
A complete list of all node.js modules created on June 24, 2013
You can also use:
https://www.npmjs.org/
|
Display complete list:
npm search
Search for a particular word in the registry name, description, author or keywords:
npm search <word>
Example:
npm search iban
|
To view the content of a package.json file of a module
|
npm view <module>
Example:
npm view express
|
Show npm version
|
npm -v
|
To uninstall a module from the local node_modules directory
|
npm uninstall <module>
Example:
npm uninstall express
|
To uninstall a module from the global node_modules directory
|
npm uninstall <module> -g
Example:
npm uninstall express -g
|
Uninstall a module or modules from the local node_modules directory when a module or modules is/are removed
from the dependencies list in the package.json file.
Example:
According to this package.json file,
two local modules (node-markdown and twitter) will be installed in the node_modules folder, when the command
npm install is executed in the project folder.
If you remove the twitter module from dependencies list in the package.json file, this module will be removed from the
node_modules folder, when the command npm prune is executed in the project folder.
|
npm purge
|
To publish a package to the npm registry
Note:
The node project directory must contain a package.json file.
The "npm publish" command must be executed in the same directory where the package.json file is located.
|
npm publish
|
To completely remove a package from the npm registry
|
npm unpublish --force <package_name>
Example:
npm unpublish --force mypackage
|
Show all possible properties for the package.json file
|
npm help json
|
Show all user installed packages
|
npm list -g --depth=0
|