Summarize the NPM commands commonly used in daily development

Source: Internet
Author: User

The NPM command has a lot of parameters, but there are a few things that you can really use in your daily work, and here's a simple summary of some of the command parameters we use more frequently.

1. Install/uninstall command Install,uninstall, RM

There are two types of package installation: local and global, the simple understanding is that the use of the scope is different, local only for the specified project under use, and the global can be applied to any project supported by Nodejs

Generally we use the package to install the main three kinds:
1.NPM install + Install without parameters, the installation will search the specified current command line directory under the Package.json file and then automatically install the package described inside, if the file does not exist the installation will fail

2.MPM install Youpackage =>install followed by package name, installs the latest version of the specified package
3.NPM install [email protected] =>install with parameters, installs the specified version of the package

If you want to install a global package, add-G after it, for example:
NPM INSTALL-G Express +> Global Install latest version of Express package

PS: Installation package also has--save,--save-dev and other commands, if interested can go to check their use

Package uninstallation: Using Uninstall or RM
Uninstall local mode installation package: NPM Uninstall Youpackage
Uninstalling the Global mode installation package: NPM uninstall-g youpackage

Using RM: NPM RM youpackage

2. Updating package update

Updates to packages can use the command update
NPM update = Updates the current project package to the latest version (the new NPM does not update the package dependencies to the latest version)
NPM update-g = Update Global package to latest version

3. Initial Package.json file init

When creating a new project, we typically initialize a Package.json file that describes the dependencies of the packages currently used by project, and the init command is a live
NPM init = = If the Package.json file does not exist under the current folder, a new one will be created at the same time to complete initialization work

4. View the installed package List/ls

If you want to see the package installed under the current project and its dependencies can be viewed through the ls/list parameter
NPM ls or NPM list = view the packages installed under the current project and the dependencies of the package
NPM ls-g, NPM list-g = view installed global packages and package dependencies

5. Want to know more about a package using docs or home commands

NPM Docs youpackage
NPM Home Youpackage = will open the Web site associated with the package
Ps:docs and Home Command open the Package Association home page is the URL that is used when the package is registered/published to access the specified site


The others are:
= = If you want to publish the package, you can use Publish/unpublish
+ Find Package Use Search
+/-Package compilation uses build/rebulid,rebulid primarily for C + + addons updates especially after you upgrade node, some packages need to be rewritten for normal use
+-View the details of a package (version, dependencies, etc.) using view, for example: NPM view Youpackage

Learn more about the NPM documentation available on the official website

Summarize the NPM commands commonly used in daily development

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.