安装Electron

由于@electron/get包的修改,使上文中方法无效,解决方式为使用:

  1. # 命令安装。
  2. $ ELECTRON_MIRROR="https://cdn.npm.taobao.org/dist/electron/" npm install electron -S
  3. $ ELECTRON_MIRROR="https://cdn.npm.taobao.org/dist/electron/" npm install electron@5.0.8 -S
  4. $ ELECTRON_MIRROR="https://cdn.npm.taobao.org/dist/electron/" yarn add electron -S

指定target编译Addon

国内淘宝atom-shell headers镜像地址:

  1. node-gyp rebuild --target=5.0.8 --arch=x64 --dist-url=https://npm.taobao.org/mirrors/atom-shell/
  1. node-gyp rebuild --target=5.0.8 --dist-url=https://atom.io/download/atom-shell
  1. node-gyp rebuild --target=5.0.8 --dist-url=https://electronjs.org/headers

教程

文章 地址 说明
electron安装缓慢问题 https://www.ghosind.com/2019/02/28/install-electron-slowly
国内配置Electron开发环境正确方式 https://blog.yasking.org/a/zh-install-electron-development-2020.html
webpack electron tempalte electron-webpack-quick-start
Electron常见问题收录 https://juejin.im/post/5e9325106fb9a03c60187cf5#heading-36
node file loader https://github.com/smt116/node-native-ext-loader
nodejs是如何和libuv以及v8一起合作的? https://blog.5udou.cn/#/blog/detail/nodejsShi-Ru-He-He-libuvYi-Ji-v8Yi-Qi-He-Zuo-De-Wen-Mo-You-Cai-Dan-Ou-84
abi_version_registry.json https://github.com/nodejs/node/blob/master/doc/abi_version_registry.json
Previous Releases https://nodejs.org/en/download/releases/#io-js-node-js
男大叔,如何理解NODE_MODULE_VERSION? https://newsn.net/say/electron-node-module-version.html
写一个N-API没那么难? https://juejin.im/post/5de484bef265da05ef59feb5
NODE_MODULE_VERSION值不一致引发的问题 https://www.cnblogs.com/mdorg/p/10417945.html
使用原生 Node 模块 https://www.electronjs.org/docs/tutorial/using-native-node-modules#%E4%B8%BA-electron-%E5%AE%89%E8%A3%85%E5%B9%B6%E9%87%8D%E6%96%B0%E7%BC%96%E8%AF%91%E6%A8%A1%E5%9D%97
vue electron项目搭建 https://medium.com/@bromix/electron-application-with-vue-js-and-vuetify-f2a1f9c749b8

项目搭建

Vue electron create
Vue CLI Plugin Electron Builder
electron builder
React electron create

Electron和Chrome版本对应

electron version chrome verison node version
0.37.4 N/A 6.0.0
1.1.0 50.0.2661.102. 6.1.0
2.0.0 61 8.9.3
3.0.0 66.0.3359.181 10.2.0
4.0.0 69.0.3497.106 10.11.0
5.0.0 73.0.3683.119 12.0.0

理论上,根据electron sdk使用了webgl渲染,并且使用了node-addon-api,需要使用node10.0 +版本,那么,对应兼容的版本应该是v3.0版本以上。

参考

https://www.electronjs.org/releases/stable?version=6
image.png
image.png