bytenode/bytenode

Invalid or incompatible cached data (cachedDataRejected)

mertushka opened this issue · 7 comments

I have an Electron application packaged with electron-builder. I wanted to use Bytenode, but I guess I couldn't do exactly what I wanted to do.

How can I compile the code for electron using the Bytenode API, i don't want to use the CLI.

Electron App

  • main.js
const { app } = require("electron");
const bytenode = require("bytenode");
bytenode.runBytecodeFile(`${app.getAppPath()}/index.jsc`);

Bytenode API

  • compiler.js
files.forEach(file => {
bytenode.compileFile({
filename: path.join(__dirname, "../sources/buildFiles", file), // sources/buildFiles is including electron app's source files (like index.js, preload.js)
electron: true,
compileAsModule: false,
output: path.join(__dirname, "../builder/", file.replace(".js", ".jsc")), // builder is electron app folder dest
});
});

Error

n180s

How do you run this file compiler.js?

How do you run this file compiler.js?

As usual with NodeJS

You cannot compile your .js files to .jsc using Node executable if you want them to be run through electron. They must be compiled using electron itself.

You will have to run your compiler.js with electron itself, with the ELECTRON_RUN_AS_NODE env variable set correctly.

In Windows, you will need to set it like this (using cmd.exe):

set ELECTRON_RUN_AS_NODE=true

Then:

C:\path\to\electron.exe compiler.js

Let me know if this solves your issue.

You cannot compile your .js files to .jsc using Node executable if you want them to be run through electron. They must be compiled using electron itself.

You will have to run your compiler.js with electron itself, with the ELECTRON_RUN_AS_NODE env variable set correctly.

In Windows, you will need to set it like this (using cmd.exe):

set ELECTRON_RUN_AS_NODE=true

Then:

C:\path\to\electron.exe compiler.js

Let me know if this solves your issue.

I've tried it, and I still get the "Invalid or incompatible cached data" error after compiling to 32-bit.
The weird thing is that compiling to 64-bit is normal.

To get this clear, how did you compile to 32-bit? Using the 32-bit exe itself or using some kind of cross-compilation?

To get this clear, how did you compile to 32-bit? Using the 32-bit exe itself or using some kind of cross-compilation?

Packaged as 32-bit using "electron-builder"

Again, you CANNOT do that. You MUST use the SAME executable to compile the files AND to run your code.

What you have done is simply compiling using the 64-bit, then you asked electron-builder to take these files and bundle them with the 32-bit executable. Do you see the issue now?

Please pay attention, the SAME EXACT ELECTRON EXE MUST be used in both compiling AND running your end product.