npm和yarn使用国内阿里云镜像加速

npm和yarn使用国内阿里云镜像加速

2020-12-06 07:21:24  |   3614  1   0  |   node npm yarn 镜像


做前端开发的人或多或少应该会使用nodejs的开发工具, 比如webpack, lessc, uglify-js等, 如果不对npm或yarn进行配置直接执行安装的时候, 就一个字, 慢, 其实npm的官方服务器在国外, 慢不是很正常吗? 你懂的

如果要解决安装慢, 老失败的问题也简单, 使用国内的镜像就行了, 我比较常用的是阿里云的镜像

可以在终端或命令提示符或PowerShell里面执行下面的命令设置

npm

npm config set registry https://registry.npm.taobao.org --global
npm config set disturl https://npm.taobao.org/dist --global

yarn

yarn config set registry https://registry.npm.taobao.org --global
yarn config set disturl https://npm.taobao.org/dist --global

这样设置过后, 以后再执行npm install或yarn add的时候就会自动使用阿里云的服务器进行下载

版权声明:自由转载-非商用-非衍生-保持署名

发表时间:2020-12-06 07:21:24

相关标签: node npm yarn 镜像

原文地址:https://www.cnblogs.com/mouseleo/p/14091929.html