node. JS Learning Notes under Windows (3)---NPM

Source: Internet
Author: User

1. What is NPM

NPM is the package Manager for node. JS, which allows developers to create, share, and reuse modules in node. JS applications. Before we installed node. JS through the Setup program on node's official website, NPM was already loaded.

Since NPM is a node. js Package Manager, what is a package?

Package: A package is a folder that encapsulates modules for release, update, dependency management, and version control. You can simply interpret the package as a folder. Package.json Description of some information about the package

Module: A file that implements some specific functionality for modular programming.

2. How to install Modules for node. JS using NPM

Enter NPM under CMD to see if NPM can be used

The node. JS version is installed on Windows: v0.10.30. Because the default installation path is not used, you need to create a file named NPM in the path of error, do not bring the suffix name oh. The error path is: C:\Users\ "Your user name" \appdata\roaming\ this path to build a NPM file can use the NPM command!

You can then enter NPM to see the system text returned by the system.

This module can be installed using NPM Install module name, NPM will automatically network to download this package

Then we'll find that we have one more folder in our project directory.

Open the above folder, and found that we have just downloaded the cookie this module.

Then open the cookie folder, which has a Package.json file, which describes the cookie packet information

Open Package.json, find "main": "Index.js", Index.js This is the junction file of this package.

Open the Index.js and find the code as shown. The 2 functions of serialize,parse are exposed by module.exports. When other JS files are introduced into this module via require, these 2 methods can be called.

Module.exports and exports are the same.

3. How to remove this module

Remove the module by using the NPM Remove module name

node. JS Learning Notes under Windows (3)---NPM

Related Article

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.