I’ve made a simple notes app using HTML, CSS and Javascript, and now i want to turn it into a desktop application, i’m using the Electron framework to achieve it, but for some reason i can’t launch the application for testing purposes.
i typed “npm start” on the code editor terminal to launch the application, but instead it outputs the following log:
> [email protected] start
> electron .
[17011:0428/235408.856171:ERROR:bus.cc(407)] Failed to connect to the bus: Failed to connect to socket /var/run/dbus/system_bus_socket: No such file or directory
[17011:0428/235408.946582:ERROR:ozone_platform_x11.cc(244)] Missing X server or $DISPLAY
[17011:0428/235408.946601:ERROR:env.cc(258)] The platform failed to initialize. Exiting.
/workspaces/Notes-App/node_modules/electron/dist/electron exited with signal SIGSEGV
Additional information (if useful).
the main.js file is on the root directory of the project, and the HTML, CSS and Javascript of the website is on a folder called “src” on the root directory, as this screenshot shows:
Main.js code:
const { app, BrowserWindow } = require('electron');
function createWindow() {
const win = new BrowserWindow({
width: 800,
height: 600,
});
win.loadFile('src/index.html');
}
app.whenReady().then(createWindow);
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') app.quit();
})
script.js code (the code that saves the notes app text on browser):
var textarea = document.querySelector('textarea');
textarea.addEventListener("input", function () {
var textWritten = textarea.value;
localStorage.setItem("written", textWritten);
});
var written = localStorage.getItem("written");
if (written) {
textarea.value = written;
}