查看npm版本

npm -v

npm查看所有版本

npm view npm versions

npm更新到最新版

npm install -g npm

查看npm当前镜像源

npm config get registry

设置npm镜像源为淘宝镜像

npm config set registry https://registry.npm.taobao.org/

 

yarn安装,参考:Yarn for mac 安装教程

查看yarn版本

yarn -v

yarn查看所有版本

npm view yarn versions

yarn更新到最新版

npm install yarn@latest -g

yarn 升级指定版本

yarn upgrade v1.21.3

yarn 降低到指定版本(先卸载,再安装)

npm uninstall yarn -g
npm install -g yarn@1.3.2

查看yarn当前镜像源

yarn config get registry

设置yarn镜像源为淘宝镜像

yarn config set registry https://registry.npm.taobao.org/

镜像源地址

npm --- https://registry.npmjs.org/
cnpm --- https://r.cnpmjs.org/
taobao --- https://registry.npm.taobao.org/
nj --- https://registry.nodejitsu.com/
rednpm --- https://registry.mirror.cqupt.edu.cn/
npmMirror --- https://skimdb.npmjs.com/registry/
deunpm --- http://registry.enpmjs.org/

也可以在工程目录下添加 .npmrc 文件来指定该项目的源

registry=https://registry.npm.taobao.org/

 

相关文章: