一、解决方案 A
如果你是在家中办公,可以切换到国内的 npm 镜像。
# 指定 npm 国内镜像$ npm config set registry http://mirrors.cloud.tencent.com/npm/# 或者$ npm config set registry https://registry.npmmirror.com/# 指定 Electron 的国内镜像地址$ npm config set ELECTRON_MIRROR="https://npmmirror.com/mirrors/electron/"$ npm install
二、解决方案 B
如果你是在公司办公,那么你公司的网络管理员可能已经设置了代理。需要确认 npm 的 proxy 配置是否指向了公司的代理服务器,以及是否配置了环境变量 ELECTRON_GET_USE_PROXY,如无配置,请按以下步骤执行。
1. 设置 npm 代理 : npm config set all_proxy=[你的代理地址]。
2. 配置 ELECTRON_GET_USE_PROXY 环境变量,这样 Electron 的安装脚本就会通过 npm 的代理下载。
三、解决方案 C
如果你是 Mac 环境。
$ export ELECTRON_GET_USE_PROXY=true
四、解决方案 D
如果你是 Windows 环境。
1. 右键单击计算机 > 属性 > 高级系统设置 > 环境变量。
2. 按下图操作设置环境变量 ELECTRON_GET_USE_PROXY ,然后执行 npm install 或 npm install –proxy=[你的代理地址]:
五、Windows
在 Windows 系统中,可以通过以下路径的目录下获取:
C:\\Users\\<YourUsername>\\AppData\\Roaming\\<YourAppname>\\TencentCloudClass
·YourUsername:Windows 用户名。
·YourAppname:对应的应用名称。
六、MacOS
在 MacOS 系统中,可以通过以下路径的目录下获取:
~/Library/Application Support/<YourAppname>\\TencentCloudClass