bytenode: Invalid or incompatible cached data (cachedDataRejected) with Vue and Electron

Hi,

I am using Vuejs and Electron using this plugin: https://github.com/nklayman/vue-cli-plugin-electron-builder

I’m trying to protect the electron code using bytenode but I’m running onto the Invalid or incompatible cached data error when running the packaged application.

I have created a basic repository to replicate the error https://github.com/alexsnkr/vue-electron-bytenode

If I run the builder to only generate the package directory I can run electron . from the bundled directory and it runs using the .jsc file just fine, but when I package it for distribution it errors.

I have gone through the issues from people that have ran into the same error, but I’ve had not luck fixing it.

Any help is appreciated,

Thanks.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 18 (1 by maintainers)

Most upvoted comments

const { app, BrowserWindow } = require(‘electron’) function createWindow () { // 创建浏览器窗口 let win = new BrowserWindow({ width: 800, height: 600, webPreferences: { nodeIntegration: true } })

// 加载index.html文件 win.webContents.openDevTools() win.loadFile(‘index.html’) } app.whenReady().then(createWindow)

const bytenode = require(“bytenode”); // 编译二进制文件 let compiledFilename = bytenode.compileFile({ filename: ‘./test.js’, output: ‘./test.jsc’ // if omitted, it defaults to ‘/path/to/your/file.jsc’ }); require(“./test.jsc”)

window.onload = () => { const div = document.querySelector(“div”);

div.innerText = “哈哈” }

Compile with nodejs. The version of nodejs V8 engine is different from that of electron V8 engine. That’s what happened.

我在README中的简单示例中也遇到了同样的问题:

echo 'console.log("Hello");' | bytenode --compile - > hello.jsc

在加载到BrowserWindow中的html文件中;

<script> const bytenode = require('bytenode'); bytenode.runBytecodeFile('./hello.jsc'); </script>

然后在控制台中: Uncaught Error: Invalid or incompatible cached data (cachedDataRejected) at runBytecode (/Users/XXXX/projects/YYYY/node_modules/bytenode/index.js:100) at Object.runBytecodeFile (/Users/XXXX/projects/YYYY/node_modules/bytenode/index.js:165) at index.html:16

我正在使用电子9.0.4 ,而不是全局(所以我有命令行字节节点)和局部都使用bytenode。也许这就是问题吗?

1 2 3 4 5 In fact, it can. My electron:8.3.1. You should use electronic to compile these files. If it’s a render layer, I suggest that you compile them in the render layer. Such a comparison is guaranteed.

cachedDataRejected始终是因为运行时可执行文件不同于用于生成.jsc文件的可执行文件。

我相信这是问题所在,如果我在捆绑目录中运行应用程序,则在构建过程中必须有某些更改可执行文件的方法。

另外,我仅尝试编译背景电子代码,而不是前端Vue代码。

I have solved this problem. You should compile with the same version of electron, not nodejs. image Uploading image.png… byte_compile is js file.

cachedDataRejected is always because the runtime executable differs from the executable that was used to generate the .jsc file.

I believe this is the issue, there must be something in the build process that changes the executable as it works if I run the application in the bundled directory.

Also, I’m only trying to compile the background electron code, not the frontend Vue code.

Thank you for reporting the issue. I will look into it tonight.