npm Getting Started

Official website: https://www.npmjs.com/

Installation: No need to install

View the current version:

$ npm -v

Update:

$ npm install npm@latest -g

Initialization engineering

$ npm init

$ npm init --yes 默认配置

Installation package

Package.json using npm install will read the file to install the module. Installation module into two categories
dependencies and devDependencies, and the corresponding installation package installer development environment required production needs.

$ npm install

$ npm install <package_name> 

$ npm install <package_name> --save

$ npm install <package_name> --save-dev

Update Module

$ npm update

Uninstall module

$ npm uninstall <package_name>

$ npm uninstall --save lodash

Configuration npm source

  • Temporary use, the installation package by -registry parameters can

    $ npm install express --registry https://registry.npm.taobao.org

  • Global Use

      $ npm config set registry https://registry.npm.taobao.org
      // 配置后可通过下面方式来验证是否成功
      npm config get registry
      // 或
      npm info express
    
  • cnpm use

    	 // 安装cnpm
    	  npm install -g cnpm --registry=https://registry.npm.taobao.org
    
    	  // 使用cnpm安装包
    	  cnpm install express
    

Guess you like

Origin blog.csdn.net/HelloWord182/article/details/93224081