https://blog.csdn.net/qq_29689343/article/details/130164840
https://blog.csdn.net/weixin_45046532/article/details/139681731
npm | yarn | pnpm | |
---|---|---|---|
初始化 | npm init | yarn init | pnpm init |
安装依赖 | npm install | yarn install | pnpm install |
安装依赖简写 | npm i | yarn add | pnpm add |
安装具体版本 | npm install package@version | yarn add package@version | pnpm add package@version |
安装并添加到dependencies | npm install --save/-S | yarn add | pnpm add |
安装并添加到devDep | npm install --save-dev/-D | yarn add --dev/-D | pnpm add --save-dev? |
卸载 | npm uninstall | yarn remove | pnpm remove |
清除缓存 | npm cache clean | yarn cache clean |
npm config get registry // 查看npm当前镜像源
npm config set registry https://registry.npmmirror.com/ // 设置npm镜像源为淘宝镜像
npm cache clean --force //清除缓存
yarn config get registry // 查看yarn当前镜像源
yarn config set registry https://registry.npm.taobao.org/ // 设置yarn镜像源为淘宝镜像
yarn cache clean
pnpm get registry
pnpm config set registry https://registry.npmmirror.com/
常用镜像源
npm --- https://registry.npmjs.org/ 官方镜像源
cnpm --- https://r.cnpmjs.org/ 国内镜像源
taobao --- https://registry.npmmirror.com/ 淘宝镜像源
nj --- https://registry.nodejitsu.com/
rednpm --- https://registry.mirror.cqupt.edu.cn/
npmMirror --- https://skimdb.npmjs.com/registry/
deunpm --- http://registry.enpmjs.org/
阿里云镜像:https://npm.aliyun.com/
中国科技大学镜像:https://mirrors.ustc.edu.cn/npm/
华为云镜像:https://mirrors.huaweicloud.com/repository/npm/
七牛云镜像:https://npm.qiniu.com/
镜像源切换 nrm
npm install -g nrm
//验证 nrm 是否安装成功
nrm --version
//查看所有镜像源
nrm ls
// 使用淘宝镜像源
nrm use taobao
//添加新的镜像源
nrm add <registry-name> <registry-url>
//删除镜像源
nrm del <registry-name>
// 切换当前使用的镜像源
nrm use <registry-name>
// 测试所有镜像源的速度
nrm test
网友评论