npm mirror

今天晚上想要将clone下来的项目进行 npm install ,但是等了半天都没动

查看源

root@VM-0-4-ubuntu:~# npm config get registry
https://registry.npmjs.org/

root@VM-0-4-ubuntu:~# npm config list
; cli configs
metrics-registry = "https://registry.npmjs.org/"
scope = ""
user-agent = "npm/6.12.0 node/v12.13.0 linux x64"

; node bin location = /opt/apps/node-v12.13.0-linux-x64/bin/node
; cwd = /root
; HOME = /root
; "npm config ls -l" to show all defaults.

https://registry.npmjs.org/ 国外的节点

每次用npm的,因为走国外的镜像,非常的慢

通过改变默认npm镜像代理服务,可以大幅提升安装速度

##方法

  1. 命令行指定(临时)
root@VM-0-4-ubuntu:~# npm --registry https://registry.npm.taobao.org info underscore 

underscore@1.9.1 | MIT | deps: none | versions: 35
JavaScript's functional programming helper library.
http://underscorejs.org

dist
.tarball: https://registry.npm.taobao.org/underscore/download/underscore-1.9.1.tgz
.shasum: 06dce34a0e68a7babc29b365b8e74b8925203961

maintainers:
- jashkenas <jashkenas@gmail.com>
- jridgewell <justin+npm@ridgewell.name>

dist-tags:
latest: 1.9.1  stable: 1.9.0  

published a year ago by jashkenas <jashkenas@gmail.com>

说明:
这种方式是在使用命令时,添加 --registry https://registry.npm.taobao.org
如:

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

安装express,使用淘宝源

  1. 通过config命令(长久)
root@VM-0-4-ubuntu:~# npm config set registry https://registry.npm.taobao.org
root@VM-0-4-ubuntu:~# npm config get registry
https://registry.npm.taobao.org/

查看

root@VM-0-4-ubuntu:~# npm info underscore

underscore@1.9.1 | MIT | deps: none | versions: 35
JavaScript's functional programming helper library.
http://underscorejs.org

dist
.tarball: https://registry.npm.taobao.org/underscore/download/underscore-1.9.1.tgz
.shasum: 06dce34a0e68a7babc29b365b8e74b8925203961

maintainers:
- jashkenas <jashkenas@gmail.com>
- jridgewell <justin+npm@ridgewell.name>

dist-tags:
latest: 1.9.1  stable: 1.9.0  

published a year ago by jashkenas <jashkenas@gmail.com>
  1. 通过cnpm使用 cnpm 定制的命令行工具可以代替 npm
root@VM-0-4-ubuntu:~# npm install -g cnpm --registry=https://registry.npm.taobao.org
/opt/apps/node-v12.13.0-linux-x64/bin/cnpm -> /opt/apps/node-v12.13.0-linux-x64/lib/node_modules/cnpm/bin/cnpm
+ cnpm@6.1.0
added 680 packages from 916 contributors in 31.765s

使用cnpm

root@VM-0-4-ubuntu:~# npm info underscore

underscore@1.9.1 | MIT | deps: none | versions: 35
JavaScript's functional programming helper library.
http://underscorejs.org

dist
.tarball: https://registry.npm.taobao.org/underscore/download/underscore-1.9.1.tgz
.shasum: 06dce34a0e68a7babc29b365b8e74b8925203961

maintainers:
- jashkenas <jashkenas@gmail.com>
- jridgewell <justin+npm@ridgewell.name>

dist-tags:
latest: 1.9.1  stable: 1.9.0  

published a year ago by jashkenas <jashkenas@gmail.com>
cnpm install xxx

eg:

cnpm install express

修改了镜像源,安装就非常快了

  • qq_43638135
    妲己再美究为妃: 博主没有想过自己接一些私活干吗?我现在还没毕业,但是我也确实听说外挂市场自动化游戏脚本市场挺火热的,并且报酬也很丰厚,但是具体的我也不是很清楚,求解答。 (1个月前 #47楼) 查看回复(2) 举报 回复
    22