npm Taobao mirror modification explanation

npm Taobao mirror modification explanation

1. Top-level usage

1. Install cnpm

npm i -g cnpm --registry=https://registry.npm.taobao.org

2. Then you can install the dependent packages with cnpm

cnpm i -g vue vue-cli

3. Check with cnpm config ls

E:\My Project\2018-08>cnpm config ls
; cli configs
disturl = "https://npm.taobao.org/mirrors/node"
metrics-registry = "https://registry.npm.taobao.org/"
registry = "https://registry.npm.taobao.org/"
scope = ""
user-agent = "npm/6.3.0 node/v8.11.3 win32 x64"
userconfig = "C:\\Users\\Administrator\\.cnpmrc"

; node bin location = D:\Program Files\nodejs\node.exe
; cwd = E:\My Project\2018-08
; HOME = C:\Users\Administrator
; "npm config ls -l" to show all defaults.


E:\My Project\2018-08>

You will find that the registry has become a Taobao mirror (warehouse): https://registry.npm.taobao.org/

[The "mirror" in this article is equivalent to the "warehouse", the same below]

2. Original npm

1. View the original configuration npm config ls

E:\My Project\2018-08>npm config ls
; cli configs
metrics-registry = "https://registry.npmjs.org/"
scope = ""
user-agent = "npm/5.6.0 node/v8.11.3 win32 x64"

; userconfig C:\Users\Administrator\.npmrc
cache = "D:\\Program Files\\nodejs\\node_cache"
prefix = "D:\\Program Files\\nodejs\\node_global"

; builtin config undefined

; node bin location = D:\Program Files\nodejs\node.exe
; cwd = E:\My Project\2018-08
; HOME = C:\Users\Administrator
; "npm config ls -l" to show all defaults.


E:\My Project\2018-08>

You will find that the registry inside is the original image of npm: https://registry.npmjs.org/

2. npm temporarily uses Taobao mirror to install dependent packages

npm i -g express --registry https://registry.npm.taobao.org

3. npm uses Taobao mirror to install dependent packages

npm config set registry https://registry.npm.taobao.org
npm i -g express

Note that this is not recommended, because it completely sets the npm image to the Taobao image. If some of our dependent packages are only available in the npm original image but not in Taobao, it will be a tragedy. So it is best to separate npm and cnpm.

3. Some common settings

1. Check [npm and cnpm are 2 different]

npm config ls
cnpm config ls

2. Settings: mainly set cache and prefix

npm cofig set cache "D:\Program Files\nodejs\node_cache"
npm cofig set prefix "D:\Program Files\nodejs\node_global"

cnpm cofig set cache "D:\Program Files\nodejs\node_cache"
cnpm cofig set prefix "D:\Program Files\nodejs\node_global"

3. Final Result

E:\My Project\2018-08>cnpm config ls
; cli configs
disturl = "https://npm.taobao.org/mirrors/node"
metrics-registry = "https://registry.npm.taobao.org/"
registry = "https://registry.npm.taobao.org/"
scope = ""
user-agent = "npm/6.3.0 node/v8.11.3 win32 x64"
userconfig = "C:\\Users\\Administrator\\.cnpmrc"

; userconfig C:\Users\Administrator\.cnpmrc
cache = "D:\\Program Files\\nodejs\\node_cache"
prefix = "D:\\Program Files\\nodejs\\node_global"

; node bin location = D:\Program Files\nodejs\node.exe
; cwd = E:\My Project\2018-08
; HOME = C:\Users\Administrator
; "npm config ls -l" to show all defaults.


E:\My Project\2018-08>npm config ls
; cli configs
metrics-registry = "https://registry.npmjs.org/"
scope = ""
user-agent = "npm/5.6.0 node/v8.11.3 win32 x64"

; userconfig C:\Users\Administrator\.npmrc
cache = "D:\\Program Files\\nodejs\\node_cache"
prefix = "D:\\Program Files\\nodejs\\node_global"

; builtin config undefined

; node bin location = D:\Program Files\nodejs\node.exe
; cwd = E:\My Project\2018-08
; HOME = C:\Users\Administrator
; "npm config ls -l" to show all defaults.


E:\My Project\2018-08>

This is the end of this article about the modification of npm Taobao mirror. For more relevant npm Taobao mirror content, please search 123WORDPRESS.COM's previous articles or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • Detailed explanation of how to modify the npm configuration item registry to Taobao mirror
  • How to configure domestic mirror resources + Taobao mirror with npm
  • Graphic tutorial on installing Vue.js using Taobao mirror cnpm
  • How to change the default global path and domestic image of npm
  • Several solutions to the failure of npm domestic mirror installation
  • Use NPM Taobao's node.js image to speed up nvm
  • Introduction and usage of domestic NPM images provided by Taobao

<<:  Tutorial on installing MySQL 5.7.28 on CentOS 6.2 (mysql notes)

>>:  Graphical tutorial on installing JDK1.8 under CentOS7.4

Recommend

Detailed explanation of the use of Linux seq command

01. Command Overview The seq command is used to g...

Tutorial on how to install htop on CentOS 8

If you are looking to monitor your system interac...

How to create a web wireframe using Photoshop

This post introduces a set of free Photoshop wire...

Detailed Example of CSS3 box-shadow Property

CSS3 -- Adding shadows (using box shadows) CSS3 -...

The front end creates and modifies CAD graphics details through JavaScript

Table of contents 1. Current situation 2. Create ...

Practical operation of using any font in a web page with demonstration

I have done some research on "embedding non-...

Vue realizes the palace grid rotation lottery

Vue implements the palace grid rotation lottery (...

How to configure domestic sources in CentOS8 yum/dnf

CentOS 8 changed the software package installatio...

Why not use UTF-8 encoding in MySQL?

MySQL UTF-8 encoding MySQL has supported UTF-8 si...

Use of Zabbix Api in Linux shell environment

You can call it directly in the Linux shell envir...

Analysis of the process of deploying pure HTML files in Tomcat and WebLogic

1. First, the pure HTML file must have an entry i...

Notes on matching MySql 8.0 and corresponding driver packages

MySql 8.0 corresponding driver package matching A...

Media query combined with rem layout in CSS3 to adapt to mobile screens

CSS3 syntax: (1rem = 100px for a 750px design) @m...