Skip to content

Electron 环境搭建+前期准备

1. 安装 Node.js

  • 使用nvm即可 Mac/Linux
bash
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash
# 或
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.2/install.sh | bash

windows 直接去github上下载安装包即可

安装Electron

bash
npm install --save-dev electron

如果想修改下载安装的位版本(例如, 在x64机器上安装ia32位版本), 你可以使用npm install中的--arch标记,或者设置npm_config_arch 环境变量:

bash
npm install --arch=ia32 electron

此外, 您还可以使用 --platform 来指定开发平台 (例如, win32、linux 等):

bash
npm install --platform=win32 electron

注意

若需要支持windows32位系统, 请使用--arch=ia32参数 这样安装的electron才能在32位系统上运行

bash
npm install --arch=ia32 --platform=win32 electron

安装失败请,尝试使用国内镜像

bash
npm config set electron_mirror https://registry.npmmirror.com/-/binary/electron/

验证是否安装成功

bash
npx electron -v

npm版本低于5.2.0时, 请使用./node_modules/.bin/electron -v来验证

更多安装问题

https://www.electronjs.org/zh/docs/latest/tutorial/installation

React+Typescript+Electron 开发跨平台桌面应用教程

https://blog.csdn.net/Joey_Tribiani/article/details/129930341

Contributors

作者:Long Mo
字数统计:282 字
阅读时长:1 分钟
Long Mo
文章作者:Long Mo
版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 Longmo Docs