Use of the "node. JS Learning II" NPM

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.