Is it possible to compile the main process of electron main.js
with some tool? I am using nexe
to compile the main process main.js
but it doesn't work.Is there a way to do that?
I am using https://github.com/electron/electron-quick-start
Then I use nexe main.js
to generate a compilation.
Then I modify package.json
by changing the value of main.js
to main.exe
.
Finally npm start
and I get an error message:
MZ´┐¢
SyntaxError: Invalid or unexpected token
at Module._compile (internal/modules/cjs/loader.js:895:18)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1004:10)
at Module.load (internal/modules/cjs/loader.js:815:32)
at Module._load (internal/modules/cjs/loader.js:727:14)
at Function.Module._load (electron/js2c/asar.js:769:28)
at loadApplicationPackage (C:\Users\Onimac\AppData\Roaming\npm\node_modules\electron\dist\resources\default_app.asar\main.js:109:16)
at Object.<anonymous> (C:\Users\Onimac\AppData\Roaming\npm\node_modules\electron\dist\resources\default_app.asar\main.js:155:9)
at Module._compile (internal/modules/cjs/loader.js:967:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1004:10)
at Module.load (internal/modules/cjs/loader.js:815:32)
Minified main.js code:
const {app, BrowserWindow} = require('electron');
function createWindow () {
const mainWindow = new BrowserWindow({
width: 800,
height: 600
})
mainWindow.loadFile('index.html')
}
app.whenReady().then(() => {
createWindow()
})