NPM Install, NPM init, NPM update, NPM Uninstall, and Package.json

Source: Internet
Author: User

NPM Install Local Pack

npm install <package_name>: This command creates the Node_modules directory in the current directory (if it does not already exist) and downloads the package to that directory. the command is installed locally by default.

Which version of the software package is installed?

If there is no Package.json file in the local directory, the latest version of the package is installed.

If there is a Package.json file, install the latest version of the Semver rule that satisfies the package (if any) that is declared in Package.json.

Install Global Packages

npm install -g <package>: Global installation package.

PACKAGE.JSONNPM Init

npm init: This command is used to create a package.json.

npm init --yesOr npm init -y : Generates the default Package.json from the information that is extracted from the current directory. No questions are raised during the creation process.

If you already have a Package.json file in your directory and you run it, npm install NPM will look at the dependencies in that file and download the latest version that meets all of them.

The description in the Package.json file helps people find your package in NPM search, so it's useful to have a custom description in Package.json.

You can also fully customize the contents of the Package.json file and the issues raised during Init. This is done by creating a custom. Npm-init.js. By default, NPM will find your home directory./. Npm-init.js

Dependencies and Devdependencies

Dependencies and Devdependencies Specify the packages that the project depends on.

    • Dependencies: These packages are needed in production.

    • Devdependencies: These packages are used for development and testing.

npm install <package_name> --saveThe command adds entries to the Package.json dependencies.
npm install <package_name> --save-devThe command adds entries to the Package.json devdependencies.

NPM Update updates Local package

npm update: Used to update dependent packages. You need to run the command in the same directory as the Package.json file.

Update Global Packages

npm update -g <package>: Updates the global package.
npm update -g: All global packages are updated.
npm outdated -g --depth=0: Locate the package that needs to be updated.

NPM Uninstall uninstalling Local Packages

npm uninstall <package>: Removes a package from the Node_modules directory.

npm uninstall --save <package>: Removes a package from the dependencies of Package.json.

npm uninstall --save-dev <package>: Removes a package from the devdependencies of Package.json.

In practice, the discovery uses npm uninstall <package> not only to delete the package in the Node_modules directory, but also to delete the information in the dependencies or devdependencies of the package in Package.json.

Uninstalling Global Packages

npm uninstall -g <package>: Uninstalls the global package.

Summary : The local command plus-G is the global command.

Reference from: NPM

Original link: 1190000010001155

NPM Install, NPM init, NPM update, NPM Uninstall, and Package.json

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.