npm is usually short for Node Package Manager, and there exists many other alias.
In my opinion, the relationship between Node.js and npm is just similar with Maven on Java, PIP on Python and GEM on Ruby.
With npm, you could manage the dependencies of your Node.js projects with ease.
The basic usage of npm includes dependencies management, module management and scripts.
Surely it is better to refer the documentation of npm or via
man npmto read the documentation.
- Install the dependencies of a projects
- Install a module
npm install express
- Install a module as project’s dependency
npm install express --save
- Install a module as project’s dev-dependency
npm install express --save-dev
- Initial a module
This command only create a package.json for your module, and will not create other files.
- Publish a module
No matter whether it is the first time you publish it, use this command. And it is a must to
npm adduse before you publish.
Due to the existence of “GFW”, developers in China can use Taonpm as the mirror of npm and install modules without panic.