Summary of npm

Summary of npm

  • definition
  • Install and check if the installation is successful
  • Initialize the project
  • version
  • Installation package
  • Uninstall package
  • Update package
  • View global installation address
  • View package list
  • help
  • Specify the installation source

definition

Node.js comes with package (plug-in, library) file manager

Install and check if the installation is successful

1.window+R enter cmd
2.node -v to view the version of node
3.npm -v to view the version of npm

	eg:eg:C:\Users\Administrator>node -v

Insert picture description hereIf the version number appears, it means that node.js is installed successfully

	eg:C:\Users\Administrator>npm -v

Insert picture description here
If the version number appears, it means that npm is installed successfully

version

The format is as
explained in XYZ :
X Destructive version update (X version changes will lead to compatibility)
Y. Do not destroy any content New features
Z. Recover minor errors

Installation package

cmd command: npm install package name
For example, install a jquery package:

	eg:npm install jquery

When installing multiple packages:
cmd command: npm install package name 1 package name 2

	eg:npm install jquery bootstrap
  • Classification of packages

1. The product (production) environment depends on the package (this is the default method)
cmd command: npm install package name --save

	eg:npm install less --save
	// 简写:npm i less -S			  S为大写

2. The development environment depends on the package
cmd command: npm install package name --save-dev

	eg:npm install less --save-dev
	// 简写:npm i jquery -D	 	      D为大写

3. Global environment
cmd command: npm install package name -g

	eg:npm install jquery -g		//g为小写

When installing a specified version of a package
cmd command: npm i package@version

	eg:npm i [email protected]

Uninstall package

cmd command: npm uninstall package name or npm remove package name

	eg:npm uninstall jquery

When uninstalling multiple packages, the operation is similar to installing multiple packages

Update package

cmd command: npm update package name

	eg:npm update jquery

Note: The update will not update the maximum, that is, the X in (XYZ) will not change

View global installation address

	eg:npm rppt view -g

View package list

	eg:npm list					//查看所有列表
	eg:npm list --depth=0		//只查看根层
	

View installation help

cmd命令:npm 命令 -h
	eg:npm install -h

Specify the installation source

Reasons for specifying the installation source: The packages we downloaded are all downloaded from foreign servers. The installation may be slower in China, especially for some large-scale frameworks. It is obvious that there are some large companies in China that copy the content mirroring to the domestic server. , We can make the download faster by specifying the installation source.
Steps:
1. Install the source management plug-in
cmd command as follows:

	eg:npm i nrm -g

2. View the available installation source
cmd commands as follows:

	eg:rnm ls

3. Use Taobao server as the download source (all installations will be downloaded from Taobao) The
cmd command is as follows:

	eg:nrm user taobao

4. For this installation, the download of jquery will be downloaded from the specified domain name

	eg:npm install jquery --registry=https://registry.npm.taobao.org

Guess you like

Origin blog.csdn.net/qwer_1014_/article/details/114269708
NPM