NPM is a package management tool that is installed with node. js to address many of the problems with Nodejs code deployment, with the following common usage scenarios:
Allow users to download third-party packages written by others from the NPM server to local use
Allow users to download and install command-line programs written by others from the NPM server to local use
Allows users to upload their own packages or command-line programs to the NPM server for others to use
Since NPM has been integrated with the new version of Nodejs, NPM has been installed as well, and it is also possible to test the installation success by entering "Npm-v". The command below shows that the version number indicates that the installation was successful.
// In the Windows environment C:\USERS\LENOVO>NPM-v3.6.0
If you need to upgrade NPM, use the following command under Windows
NPM Install Npm-g
Installing the module using the NPM command
NPM installs the node. JS module syntax as follows
NPM Install <module name>
For example, we use the NPM command to install the Common node. JS Web Framework Module Express
NPM Install Express
When installing, be aware that under Windows, the NPM Install command must be used under the Nodejs root directory, or the installation location will be wrong
Once installed, the Express package is placed in the Node_modules directory under the project directory, so you only need to pass require ("Express") in the code, without specifying a third-party package path.
var express = Require ("Express");
Use of the "node. JS Learning II" NPM