electron-vue安装与打包问题解决
electron-vue安装与打包问题解决
1.项目安装
报错
RequestError: connect ETIMEDOUT 185.199.109.133:443
RequestError: socket hang up
问题
- npm国内下载时存在网络连接失败以及网络缓慢的情况,需要使用镜像安装
- 设置npm镜像地址,安装vue-electron时镜像地址没有应用
解决
- 单独为electron设置镜像地址:
npm config set electron_mirror https://npmmirror.com/mirrors/electron/
- 执行安装:
npm install
2.项目打包
此处参考博客
报错
cannot resolve https://npmmirror.com/mirrors/electron/9.2.1/electron-v9.2.1-win32-ia32.zip: status code 404
问题
electron-builder生成的包路径与实际淘宝镜像包路径有差异,导致无法获取到对应的electron包
npm包地址:https://npmmirror.com/mirrors/electron/9.2.1/electron-v9.2.1-win32-ia32.zip
镜像地址:https://npmmirror.com/mirrors/electron/v9.2.1/electron-v9.2.1-win32-ia32.zip
解决
- 在electron镜像地址
https://registry.npmmirror.com/binary.html?path=electron/v9.2.1/
下载对应的electron-v9.2.1-win32-x64.zip
和electron-v9.2.1-win32-ia32.zip
(根据实际的版本包进行调整) - 将两个包放入
C:\Users\用户\AppData\Local\electron\Cache
,打包时可直接从缓存中获取而不需要再通过网络请求 - 执行打包:
npm run build