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!
相关推荐
Johny_Zhao1 天前
OpenClaw安装部署教程
linux·人工智能·ai·云计算·系统运维·openclaw
一拳不是超人2 天前
Electron主窗口弹框被WebContentView遮挡?独立WebContentView弹框方案详解!
前端·javascript·electron
chlk1232 天前
Linux文件权限完全图解:读懂 ls -l 和 chmod 755 背后的秘密
linux·操作系统
舒一笑3 天前
Ubuntu系统安装CodeX出现问题
linux·后端
改一下配置文件3 天前
Ubuntu24.04安装NVIDIA驱动完整指南(含Secure Boot解决方案)
linux
深紫色的三北六号3 天前
Linux 服务器磁盘扩容与目录迁移:rsync + bind mount 实现服务无感迁移(无需修改配置)
linux·扩容·服务迁移
SudosuBash3 天前
[CS:APP 3e] 关于对 第 12 章 读/写者的一点思考和题解 (作业 12.19,12.20,12.21)
linux·并发·操作系统(os)
哈基咪怎么可能是AI4 天前
为什么我就想要「线性历史 + Signed Commits」GitHub 却把我当猴耍 🤬🎙️
linux·github
十日十行4 天前
Linux和window共享文件夹
linux
木心月转码ing5 天前
WSL+Cpp开发环境配置
linux