question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot require bytenode jsc file in electron

See original GitHub issue

Hi. Please help me in this case. I’m using electron-vuejs template from this https://github.com/SimulatedGREG/electron-vue This project, it didn’t use command electron ., but using a js file to start electron. You can check in package.json (https://github.com/SimulatedGREG/electron-vue/blob/master/template/package.json) "dev": "node .electron-vue/dev-runner.js",

When I require bytenode jsc file in this js file (dev-runner.js), it works. But when I require jsc file in src/main/index.js , it show error

ERROR in ./src/main/config.jsc 1:0 Module parse failed: Unexpected character ‘�’ (1:0) You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders (Source code omitted for this binary file) @ ./src/main/index.js 7:13-36 @ multi ./src/main/index.dev.js ./src/main/index.js

Can you please check it ?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:8

github_iconTop GitHub Comments

1reaction
reiinii1commented, Feb 9, 2021

Hey there, I solved the same problem by using __non_webpack_require__(fileLocation) in the main process or require('electron').remote.require(fileLocation) in the render process (Vue.js).

Example main.js

bytenode.compileFile({
    filename: 'src/secret.js',
    output: 'public/secret.jsc',
    compileAsModule: true
});
const fileLocation = path.join(__static, 'secret.jsc'); /* global __static */
const secretFunctions = __non_webpack_require__(fileLocation);

Example HelloWorld.vue

<template>
    <div class="hello">
        <h3>Simple Login Example</h3>
        <label>Username<br /><input type="text" v-model="username" /></label><br /><br />
        <label>Password<br /><input type="password" v-model="password" /></label><br /><br />
        <button @click="login">Login</button>
        <p>Valid user: {{ success }}</p>
    </div>
</template>

<script>
const path = require('path');
const fileLocation = path.join(__static, 'secret.jsc'); /* global __static */
const secretFunctions = require('electron').remote.require(fileLocation);

export default {
    name: 'HelloWorld',
    data() {
        return {
            success: false,
            username: '',
            password: '',
        };
    },
    methods: {
        login() {
            this.success = secretFunctions.login(this.username, this.password);
        },
    },
};
</script>
1reaction
boygiandicommented, Jan 4, 2021

thank you

Read more comments on GitHub >

github_iconTop Results From Across the Web

Production Build with .jsc electron file · Issue #73 - GitHub
Hey i have a electron-main.jsc file compiled using bytenode. ... Also, I guess that you can not use a .jsc file as your...
Read more >
How to Compile Node.js Code Using Bytenode? - HackerNoon
bytenode cli: bytenode --run my-file.jsc. Now you know how to compile .js files, how to require the compiled version in your code, and...
Read more >
How do I reverse engineer an Electron compiled file?- a JSC ...
I have a bytenode JSC file - which is described as: This tool truly compiles your JavaScript code into V8 bytecode, so that...
Read more >
bytenode - Bountysource
jsc files? I know main reason to use bytenode is to hide source code when distributed, but it can be useful to have...
Read more >
How we bypassed bytenode and decompiled Node.js ...
A parser for JSC file headers is required. We need to (try to) look into the inner workings of the V8 engine, into...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found