切换镜像
npm config get registry // 查看npm当前镜像源
npm config set registry https://registry.npm.taobao.org/ // 设置npm镜像源为淘宝镜像
npm config set registry https://registry.npmjs.org/ // 设置默认镜像源
yarn config get registry // 查看yarn当前镜像源
yarn config set registry https://registry.npm.taobao.org/ // 设置yarn镜像源为淘宝镜像
yarn config set registry https://registry.yarnpkg.com // 设置默认镜像源
镜像工具
npm镜像工具
npm install -g nrm
nrm ls
nrm use taobao
nrm add <registry> <url>
nrm del <registry>
nrm test<registry>
yarn镜像工具
npm install -g yrm
yrm ls
yrm use taobao
yrm add <registry> <url>
yrm del <registry>
yrm test<registry>
常用指令
| npm | yarn |
|---|
| 初始化 | npm init | yarn init |
| 安装包 | npm install / i 包 | yarn add 包 |
| 更新包 | npm update / up包 | yarn up 包 |
| 删除包 | npm uninstall 包 | yarn remove 包 |
| 查看下载的包 | npm list / ls -g | |
| 安装所有依赖 | npm install / i | yarn / yarn install |
| 版本升级 | npm i npm@version -g | yarn set version latest |
| 运行scripts | npm run 指令 | yarn 指令 |
包更新工具
npm install -g npm-check
npm-check -u -g