代理设置
设置代理和https代理1
2npm config set proxy=http:/server:port
npm config set https-proxy http://server:port
认证用户名和密码1
2npm config set proxy http://username:password@server:port
npm confit set https-proxy http://username:password@server:port
删除代理1
2npm config delete proxy
npm config delete https-proxy
镜像源设置
1 | npm config set registry http://registry.npmjs.org |
全局配置文件设置
npm config edit
打开.npmrc
文件 ,在文件中如下位置添加如下代码1
2
3
4
5
6
7
8
9
10
11
12
13;;;;
; npm userconfig file
; this is a simple ini-formatted file
; lines that start with semi-colons are comments.
; read `npm help config` for help on the various options
;;;;
registry=http://registry.npmjs.org/
proxy=http://10.127.0.0.1:1008/
;;;;
; all options with default values
;;;;
使用nrm切换npm源
安装1
npm install nrm -g
列出可用的源1
2
3
4
5
6
7 nrm ls
npm ---- https://registry.npmjs.org/
cnpm --- http://r.cnpmjs.org/
taobao - https://registry.npm.taobao.org/
nj ----- https://registry.nodejitsu.com/
npmMirror https://skimdb.npmjs.com/registry/
edunpm - http://registry.enpmjs.org/
切换1
2 npm use taobao
Registry has been set to: http://registry.npm.taobao.org/
增加源1
nrm add taobao http://registry.npm.taobao.org/
删除源1
nrm del taobao
测试速度1
nrm test taobao
npm config相关命令
1 | npm config set <key> <value> [-g|--global] |