美文网首页Js
安装Electron时卡在install.js不动的解决方案

安装Electron时卡在install.js不动的解决方案

作者: 路过麦田 | 来源:发表于2018-01-11 18:30 被阅读770次

之前在安装Electron的时候,经常会卡住,这次重新搭建环境时又卡住了

$ node install.js

卡在了这一步,半天不动,基本上可以确定,访问的electron源被墙了,搭梯子也不行,挺恼火的。

在网上搜了搜,找到了解决方案,需要给 electron 明确的指定源。

解决方案如下:

修改~/.npmrc 文件,加入如下代码:

registry=https://registry.npm.taobao.org
electron_mirror="https://npm.taobao.org/mirrors/electron/"

指定electron的源为淘宝的,再次安装,果然可以正常安装了。

网上的原因分析(自己看了一下,确实是这样的)

install.js里面的下载是依赖于electron-download这个模块,这个库有如下的注释:

You can set the ELECTRON_MIRROR or NPM_CONFIG_ELECTRON_MIRROR environment variable or mirror opt variable to use a custom base URL for grabbing Electron zips. The same pattern applies to ELECTRON_CUSTOM_DIR and ELECTRON_CUSTOM_FILENAME:
## Electron Mirror of China
ELECTRON_MIRROR="https://npm.taobao.org/mirrors/electron/"
## or for a local mirror
ELECTRON_MIRROR="https://10.1.2.105/"
ELECTRON_CUSTOM_DIR="our/internal/filePath"
You can set ELECTRON_MIRROR in .npmrc as well, using the lowercase name:

相关文章

网友评论

    本文标题:安装Electron时卡在install.js不动的解决方案

    本文链接:https://www.haomeiwen.com/subject/voetoxtx.html