npm 源设置


npm 初始源是国外,由于不可描述,我选择更换淘宝源

1.设置淘宝源

npm config set registry https://registry.npm.taobao.org

2.cnpm 中国的npm包管理器,听说会有一定几率导致未知BUG(未曾遇到过)

npm install cnpm -g
//查看设置结果
npm config list

------------结果=》
PS C:\Users\86131> npm config list
; cli configs
metrics-registry = "https://registry.npm.taobao.org/"
scope = ""
user-agent = "npm/6.14.5 node/v14.4.0 win32 x64"

; userconfig C:\Users\86131\.npmrc
registry = "https://registry.npm.taobao.org/"

; builtin config undefined
prefix = "C:\\Users\\86131\\AppData\\Roaming\\npm"

; node bin location = C:\Program Files\nodejs\node.exe
; cwd = C:\Users\86131
; HOME = C:\Users\86131
; "npm config ls -l" to show all defaults.

3.yarn 非常好用,可以媲美npm的包管理器

npm install yarn -g
//设置源
yarn config set registry https://registry.npm.taobao.org/  // 设置yarn镜像源为淘宝镜像
//查看设置结果
npm config list

------------结果=》
PS C:\Users\86131> yarn config list
yarn config v1.22.4
info yarn config
{
  'version-tag-prefix': 'v',
  'version-git-tag': true,
  'version-commit-hooks': true,
  'version-git-sign': false,
  'version-git-message': 'v%s',
  'init-version': '1.0.0',
  'init-license': 'MIT',
  'save-prefix': '^',
  'bin-links': true,
  'ignore-scripts': false,
  'ignore-optional': false,
  registry: 'https://registry.npm.taobao.org/',
  'strict-ssl': true,
  'user-agent': 'yarn/1.22.4 npm/? node/v14.4.0 win32 x64',
  lastUpdateCheck: 1591622366428
}
info npm config
{
  registry: 'https://registry.npm.taobao.org'
}
Done in 0.19s.

4.部分源地址如下(源地址来源:知乎

npm --- https://registry.npmjs.org/

cnpm --- https://r.cnpmjs.org/

taobao --- https://registry.npm.taobao.org/

nj --- https://registry.nodejitsu.com/

rednpm --- https://registry.mirror.cqupt.edu.cn/

npmMirror --- https://skimdb.npmjs.com/registry/

deunpm --- http://registry.enpmjs.org/