npm-手册

配置 npmmirror 镜像

  1. 备份旧镜像

在替换 npmmirror 镜像之前,我们先查看一下原有的镜像

1
npm get registry

结果为 https://registry.npmjs.org/

1
yarn get registry

结果为 https://registry.yarnpkg.com

  1. 替换为 npmmirror 镜像
1
2
3
4
# 设置 npm 的源为 npmmirror
npm config set registry https://registry.npmmirror.com
# 设置 yarn 的源为 npmmirror
yarn config set registry https://registry.npmmirror.com

升级版本

查看 npm 版本

1
npm -v

升级到最新的 npm 版本

1
npm install -g npm

安装指定版本的 npm

1
npm install -g npm@版本号