Nodejs npm commonly used commands in the detailed _node.js

Source: Internet
Author: User
Tags install node

What's NPM?

NPM's full name is Node Package Manager, the package management and distribution tool that is installed along with Nodejs, which makes it easy for JavaScript developers to download, install, upload, and manage installed packages.

NPM is a node package management and distribution tool that has become the unofficial standard for publishing node modules (packages). With NPM, you can quickly find the packages that a particular service will use, download, install, and manage the packages that are already installed.

1, NPM install Modulenames: Install node module

After installation, a node_modules directory is created, with each node module installed in its directory.

Node installation is divided into global mode and local mode.

Typically, it will run in local mode, and the package will be installed in the local Node_modules directory with your application code.
In global mode, the node package is installed under Node_modules under the node's installation directory.

The Global installation command is $NPM install-g modulename.

Learn to use the $NPM set Global=true to set installation mode, $NPM get global to view the currently used installation mode.

Example:

Copy Code code as follows:

NPM Install Express

The latest version of Express is installed by default, or you can install the specified version, such as NPM install express@3.0.6, by adding a version number later.

Copy Code code as follows:

NPM Install <name> g

To install a package into the global environment

But in code, there is no way to invoke a globally installed package directly through the require (). Global installations are intended for use by the command line, as if Vmarket were installed globally, you can run VM commands directly on the command line

Copy Code code as follows:

NPM Install <name>--save

While installing, write information to the project path in Package.json if there is a Package.json file, use the NPM install method directly to install all the dependent packages according to the dependencies configuration, so that when the code is submitted to the GitHub, You don't have to submit node_modules this folder.

2, NPM view modulenames: View the Node Module Package.json folder

Note: If you want to see the contents of a label under the Package.json folder, you can use $NPM view ModuleName labelname

3. NPM list: View the installed node packages in the current directory

Note: The node module search starts at the current directory where the code executes, and the search results depend on the content under Node_modules in the currently used directory. $ NPM List parseable=true can be in the form of catalogs to present all of the currently installed

Node Package

4. NPM Help: View the assistance commands

5. NPM View moudlename dependencies: View package dependencies

6, NPM view modulename repository.url: View the source file address of the package

7, NPM View ModuleName engines: View the version of node on which the package depends

8, NPM Help folders: View all the folders that NPM uses

9, NPM rebuild ModuleName: To change the contents of the package after the rebuild

10, NPM outdated: Check whether the package is obsolete, this command will list all the outdated packages, you can update the package in a timely manner

11, NPM update modulename: Update node module

12, NPM uninstall Moudlename: Uninstall node module

13, a NPM package is a folder containing Package.json, Package.json describes the structure of this folder. The way to access NPM's JSON folder is as follows:

Copy Code code as follows:

$ NPM Help JSON

This command opens a Web page by default and may not be opened as a Web page if you change the default open program.

14, the release of a NPM package, you need to verify that a package name exists

Copy Code code as follows:

$ NPM Search PackageName

15, NPM init: will guide you to create a Package.json file, including name, version, author of this information, etc.

16, NPM Root: View the current package installation path

NPM root-g: View the installation path for a global package

17. Npm-v: View the version of NPM installation

For more commands, please refer to NPM's official documentation: HTTPS://WWW.NPMJS.ORG/DOC/

The above is a small set to introduce the Nodejs in NPM commonly used in order to explain, hope to help everyone, if you have any questions please give me a message, small series will promptly reply to everyone. Here also thank you very much for the cloud Habitat Community website support!

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.