Reputation: 4434
I am tring merge wiki.js with electron
and, I can make simple electron application as below code
main.js
const { app, BrowserWindow } = require('electron');
const path = require('path')
var winGlobal;
// This will run express server with port 3000 within 3~6 seconds
require('./server/index.js')
// load the url after 9 seconds.
setTimeout(() => winGlobal.loadURL('http://localhost:3000'), 9000);
function createWindow() {
const win = new BrowserWindow({
width: 1200,
height: 900,
webPreferences: {
// preload: path.join(__dirname, 'preload.js')
}
})
winGlobal = win;
}
app.whenReady().then(() => {
createWindow()
app.on('activate', () => {
if (BrowserWindow.getAllWindows().length === 0) {
createWindow()
}
})
})
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit()
}
})
package.json
{
...
"main": "main.js"
...
"build": {
"productName": "wiki.js-electron",
"appId": "com.electron.wiki",
"directories": {
"output": "build"
},
"asar": true
},
"dependencies": {
...
"express": "4.17.1",
"sqlite3": "5.0.0",
...
}
"devDependencies": {
...
"electron": "^12.0.2",
"electron-builder": "^22.10.5",
...
}
}
And, I can run the current project with npx electron .
To build exe, I can build with npx electron-build
, and new exe file is generated without error log.
but, the exe is crash without any error.
How I can fix this?
Full Source code Github: https://github.com/nkhs/wiki.js-electron
Built exe: https://wetransfer.com/downloads/535a59714d4d957f478c14816ee0142e20210330143018/0d5cbe
Upvotes: 1
Views: 901
Reputation: 4434
I Found Solution Instead of running with a mouse double click at File Explorer, I used windows command prompt to run exe, and, from there, I can find error logs.
So, I found: the some relative path is not working, because, the electron pack source code with asar.
and, some file operate is not working, etc fs.read
, fs.readDir
.
Cannot access files inside asar archive in electron app ,
So, I removed this problem.
Upvotes: 2