有些项目使用npm安装依赖,有些使用yarn,常常因为依赖包版本问题,导致安装失败,特别是node-sass这个依赖安装靠的是人品。工作中遇到了这个问题,研究出一套配置,基本可以解决大部分依赖安装的奇怪问题。
配置.npmrc
将以下代码粘贴进去
配置贴出来了
canvas_binary_host_mirror=[https://registry.npmmirror.com/-/binary/canvas/](https://registry.npmmirror.com/-/binary/canvas/) sass_binary_site=[https://registry.npmmirror.com/-/binary/node-sass](https://registry.npmmirror.com/-/binary/node-sass) nodejs_org_mirror=[https://registry.npmmirror.com/-/binary/node/](https://registry.npmmirror.com/-/binary/node/) electron_mirror=[https://registry.npmmirror.com/-/binary/electron/](https://registry.npmmirror.com/-/binary/electron/) electron_builder_binaries_mirror=[https://registry.npmmirror.com/-/binary/electron-builder-binaries/](https://registry.npmmirror.com/-/binary/electron-builder-binaries/) chromedriver_cdnurl=[https://registry.npmmirror.com/-/binary/chromedriver/](https://registry.npmmirror.com/-/binary/chromedriver/)
依赖尽量使用yarn进行安装,将镜像改为淘宝源,能解决大部分依赖安装问题