0%

npm

npm is the package manager for javascript… npm is the package manager for JavaScript. Find, share, and reuse packages of code from hundreds of thousands…

npm 技巧

npm 安装依赖时指定安装源

npm 指定临时的安装源

1
2
# 安装`express`时临时指定的阿里源
npm install express --registry=https://registry.npm.taobao.org

npm 指定永久的安装源

1
2
3
# 方法一
npm config set registry https://registry.npm.taobao.org
npm info underscore (如果上面配置正确这个命令会有字符串response)
1
2
# 方法二
npm --registry https://registry.npm.taobao.org info underscore
1
2
3
# 方法三
编辑 ~/.npmrc
npm --registry https://registry.npm.taobao.org info underscore

使用nrm管理安装源

安装

1
npm install nrm -g

查看当前内置的npm源

1
nrm ls

切换到cnpm源

1
nrm use cnpm