Nodejs NPM Common Commands

Source: Internet
Author: User

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

1. NPM Install Modulenames: Installing node module

After installation, a node_modules directory is created, and the individual node modules are installed in the directory.

Node installation is divided into global mode and local mode.
Normally it will run in local mode and the package will be installed into the local node_modules directory of your application code.
In global mode, the node package will be installed under Node_modules under node's installation directory.

The Global installation command is $NPM install-g modulename.
Learn to use $NPM set Global=true to set the installation mode, $NPM get global to see the installation mode currently in use.

Example:
NPM Install Express
The latest version of Express is installed by default, or you can install the specified version by adding the version number later, such as NPM install [email protected]

NPM Install <name>-G
To install a package into a global environment

But in the code, the direct way through require () is that there is no way to call a globally installed package. The global installation is for the command line, as if the Vmarket is installed globally, you can run the VM command directly on the command line

NPM Install <name>--save
While installing, writing information to Package.json in the project path if there is a Package.json file, you can use the NPM install method to install all dependent packages based on the dependencies configuration, so that when the code is submitted to GitHub, You do not have to submit node_modules this folder.

2. NPM View Modulenames: View the Package.json folder of the node module
Note: If you want to view the contents of a tag 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. The NPM list parseable=true can be used in the form of a directory to present all node packages currently installed

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 used by NPM

9. NPM rebuild ModuleName: Rebuild after changing package contents

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

11, NPM update modulename: Update node module

12. NPM Uninstall Moudlename: Uninstalling node module

13, a NPM package is a folder containing Package.json, Package.json describes the structure of this folder. Here's how to access NPM's JSON folder:
$ NPM Help JSON
This command opens a Web page by default, and may not open as a Web page if you change the default open program.

14, when releasing a NPM package, you need to verify that a package name already exists
$ NPM Search PackageName

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

16. NPM Root: View the installation path for the current package
NPM root-g: View the installation path for a global package

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

See NPM official documentation for more commands: https://www.npmjs.org/doc/

Nodejs npm Common Commands (RPM)

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.