通过设置.yarnrc或者.npmrc,提高国内各种源下载速度:electron,sass,phantomjs,chromedriver,sharp等

x
xiezixing
发布于 4 个月前

最近的墙越来越高,对于开发者来说可不是好事,也就是开发的门槛其实是越来越高了,有时候可能下载一个环境就会把人给折腾的半死。甚至很多初学者第一次学开发,安装环境的时候就放弃了。所以这个时候就需要我们将库的源更换成国内的源,这里我就介绍下如何更换NODEJS中yarn和npm中各种库的源。

yarn可以通过源码根目录中的.yarnrc来设置,我这里有一个非常齐的源:

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

disturl "https://npm.taobao.org/mirrors/node/"
sass_binary_site "https://npm.taobao.org/mirrors/node-sass/"
phantomjs_cdnurl "http://cnpmjs.org/downloads"
electron_mirror "https://npm.taobao.org/mirrors/electron/"
sqlite3_binary_host_mirror "https://foxgis.oss-cn-shanghai.aliyuncs.com/"
profiler_binary_host_mirror "https://npm.taobao.org/mirrors/node-inspector/"
chromedriver_cdnurl "https://cdn.npm.taobao.org/dist/chromedriver"
canvas_binary_host_mirror "https://npm.taobao.org/mirrors/node-canvas-prebuilt/"
sharp_binary_host "https://npm.taobao.org/mirrors/sharp/"
sharp_libvips_binary_host "https://npm.taobao.org/mirrors/sharp-libvips/"
puppeteer_download_host "https://npm.taobao.org/mirrors/"
sentrycli_cdnurl "https://npm.taobao.org/mirrors/sentry-cli/"
python_mirror "https://npm.taobao.org/mirrors/python/"

NPM可以通过源码根目录中的.npmrc来设置,其实就跟上面的差不多:

sass_binary_site=https://npm.taobao.org/mirrors/node-sass/
registry=https://registry.npm.taobao.org
ELECTRON_MIRROR=https://npm.taobao.org/mirrors/electron/

其实就是换成=号,对应上边的yarnrc中的配置。

相关文章推荐
评论区
暂未开放
相关文章推荐