Node.js strikes me as short and tool-heavy: the language is javascript, not some new language juggler. When you first get to grips with Node.js, it’s all about CoffeeScript, Express.js, Bower, gulp, and Jade.

This includes the application of NPM.

NPM: NodeJs package manager, used to install various packages and also used for project initialization:

1. Installation package

NPM install \

Normally, this command should be run in the project root directory so that the specified package appears in the node_modules subdirectory of the root directory. If there is no node_modules, the system will automatically create one.

For example, if I want to install socket. IO, I can type:

npm install socket.io

Packages come in versions. Socket. IO is now 1.0 or older, but I want to use 0.9.

NPM install [email protected]

If a project is taken from Git, there may be no node_modules, because this can be downloaded from the web and the original author will not commit this. In this case, we can go to the project root and type:

npm install

The system will download various packages as specified in package.json in the root directory.

So package.json is important.

Now the question is, where does package.json come from? Answer:

2. Project initialization

In the project root directory, type:

npm init

The system will ask you a series of questions, type the answer, press Enter. If you don’t want to answer, you can press Enter all the way to package.json.

If I use a new package, or change the package version, I can write package.json at the same time as the installation as follows:

NPM install… save

\

\

\

\

\