'Electron not starting properly due to SIGTRAP
I am getting into Electron to try to begin building desktop applications. I am running into this error:
/home/me/dev/my-electron-app-2/node_modules/electron/dist/electron exited with signal SIGTRAP
This path leads to a binary file, so I can't really read what is happening. This error comes when I run:
npm start
My goal is to have a window appear on my desktop reflecting the HTML page. So far, the app is just:
index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<!-- https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP -->
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self'">
<meta http-equiv="X-Content-Security-Policy" content="default-src 'self'; script-src 'self'">
<title>Hello World!</title>
</head>
<body>
<h1>Hello World!</h1>
We are using Node.js <span id="node-version"></span>,
Chromium <span id="chrome-version"></span>,
and Electron <span id="electron-version"></span>.
</body>
</html>
main.js
const { app, BrowserWindow } = require('electron')
const createWindow = () => {
const win = new BrowserWindow({
width: 800,
height: 600
})
win.loadFile('index.html')
}
app.whenReady().then(() => {
createWindow()
})
This code has come from the docs, here: https://www.electronjs.org/docs/latest/tutorial/quick-start
I have googled quite a bit and have been unable to find a solution that sticks. I am using Ubuntu in WSL. If anyone has any advice it would be appreciated.
Thanks
Solution 1:[1]
Since electron is a GUI application, and you are using Ubuntu on WSL (I'm assuming WSL2?), you need to run an X server for Ubuntu have something to render the GUI on.
You can download and install VcXsrv from here: https://sourceforge.net/projects/vcxsrv/
How to configure it is explained in the top answer to this question: How to set up working X11 forwarding on WSL2
Your other option is to not use WSL; just run node, npm and electron directly on your Windows machine. Then, you will not need to install any separate X server; your app should just work.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | martin jakubik |