I’m trying to make offline desktop App by complaining NodeJS , SQLite and Electron together.
with little adjustment to package.json
‘’ ’
“scripts”: {
“start”: “./index.js”
}
’ ‘’
and my index.js
‘’ ’
const server = require(’./lib/server’);
const electron = require(‘electron’)
const path = require(‘path’)
server.start();
const BrowserWindow = electron.BrowserWindow
const app = electron.appapp.on(‘ready’, () => {
createWindow()
})let mainWindow
function createWindow() {
// Create the browser window.
const {
width,
height
} = electron.screen.getPrimaryDisplay().workAreaSize
mainWindow = new BrowserWindow({
width: 1000,
height: 800,
show: false,
autoHideMenuBar: true
})mainWindow.loadURL(‘http://localhost:3000/’)
mainWindow.webContents.once(‘dom-ready’, function () {
mainWindow.show()
mainWindow.unmaximize();
// mainWindow.webContents.openDevTools()
});const {shell} = require(‘electron’)
shell.showItemInFolder(‘fullPath’)// Emitted when the window is closed.
mainWindow.on(‘closed’, function () {mainWindow = null;
})
}// This method will be called when Electron has finished
// initialization and is ready to create browser windows.
// Some APIs can only be used after this event occurs.
//app.on(‘ready’, createWindow) // <== this is extra so commented, enabling this can show 2 windows…// Quit when all windows are closed.
app.on(‘window-all-closed’, function () {
// On OS X it is common for applications and their menu bar
// to stay active until the user quits explicitly with Cmd + Q
if (process.platform !== ‘darwin’) {app.quit();
}
})app.on(‘activate’, function () {
// On OS X it’s common to re-create a window in the app when the
// dock icon is clicked and there are no other windows open.
if (mainWindow === null) {
createWindow()
}
})
‘’ ’
however wen i start my electron app it through
’ ‘’
{“status”:“404”,“message”:"/ not found."}
‘’ ’
Without electron every think Worked ok
I found if I move the
Views , public and other folders with the EXE file outside of Resources folder it work But it's not normal ,and you have to figure which folder to move which one to keep by copying it
I thinks the issue is with routing but I can’t figure out how to make it work.
I read all topics about this but nothing is giving me a clue about How To Fix it.
Sorry for bad English and thanks
Last updated: