Ubuntu安装Electron环境

前言

Electron官方文档

要开发 Electron 应用,您需要安装 Node.js 运行环境和它的包管理器 npm。 我们推荐安装最新的长期支持 (LTS) 版本。

安装nvm

node.js的版本管理工具

复制代码
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash

安装最新的 LTS 版本的 Node.js

复制代码
nvm install --lts

验证安装

复制代码
node -v
npm -v

创建一个demo项目

复制代码
mkdir my-electron-app && cd my-electron-app
npm init

会简单配置一下package.json中的字段,回车到结束

配置代理,在项目里安装electron

复制代码
npm config set registry https://registry.npmmirror.com
npm install electron --save-dev

官方demo

创建main.js

复制代码
console.log('Hello from Electron 👋')

修改package.json

复制代码
{
  "name": "my-electron-app",
  "version": "1.0.0",
  "description": "Hello World!",
  "main": "main.js",
  "scripts": {
    "start": "electron .",
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "Jane Doe",
  "license": "MIT",
  "devDependencies": {
    "electron": "23.1.3"
  }
}

Run!

复制代码
npm run start

Hello from Electron 👋
mesa: for the --simplifycfg-sink-common option: may only occur zero or one times! 
mesa: for the --global-isel-abort option: may only occur zero or one times! 
mesa: for the --amdgpu-atomic-optimizations option: may only occur zero or one times!
相关推荐
tntxia12 小时前
linux curl命令详解_curl详解
linux
扛枪的书生14 小时前
Linux 网络管理器用法速查
linux
顺风尿一寸17 小时前
Java Socket 内核之旅:从 SocketChannel.read() 到 tcp_recvmsg 与 epoll 的完整调用链路
linux
XIAOHEZIcode1 天前
Ubuntu 终端美化全栈指南:Bash 到 Kitty 踩坑实录
linux·ubuntu·命令行
唐青枫1 天前
别再只会用 cron:Linux systemd Timer 定时任务实战详解
linux
mCell2 天前
【锐评】桌面端技术营销:别拿跑分当工程判断
前端·rust·electron
TrisighT2 天前
Electron鸿蒙PC上写日志文件,我被权限和路径坑了两次
electron·harmonyos
AlfredZhao3 天前
生产环境里,为什么不建议把普通端口直接暴露到公网?
linux·https·443·80
薛定喵的谔4 天前
Term Proxy — 用 Tauri 2 打造跨平台终端配置管理工具
electron·ai编程·全栈
逸铭4 天前
Day 5:三栏布局——左账号 / 中聊天 / 右工具
vue.js·electron