1、安装

1
2
3
4
5
6
7
npm i <package>

npm i <package> -g

npm i <package> --save-dev

npm install @myco/my-package

2、切换源

1
2
3
4
5
# 长久切换
npm config set registry <https://registry.npm.taobao.org>

# 临时切换
npm --registry https://registry.npm.taobao.org install express

3、添加私有源

1
2
3
4
5
6
7
8
9
10
// 需要先登录
npm config set <@myco>:registry <http://reg.example.com>
.npmrc
registry=https://registry.npmjs.org/
//registry.npm.dreamdev.cn/:_password=<password>
//registry.npm.dreamdev.cn/:username=<user>
//registry.npm.dreamdev.cn/:email=<email>
//registry.npm.dreamdev.cn/:always-auth=false
@myco:registry= <http://reg.example.com>
https://registry.npm.dreamdev.cn/=