Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

139
Views
ElectronJS - ERR_FILE_NOT_FOUND when using import

I am trying to learn ElectronJS. I am OK with "Vanilla" JavaScript but when it comes to Node I am clueless. Everything works when I use the tag in my html and run all the code from that .js code. However I am now trying to import a class and get an ERR_FILE_NOT_FOUND error when I launch the program. This is the basic code explaining where my problem happens.

Vector3 Class:

export class Vector3{
    constructor(x, y, z){
        this.x = x;
        this.y = y;
        this.z = z;
    }
}

Test.js file used in <script type="module" src="Test.js>

import {Vector3} from "./mathf/Vector3"

function main(){
    let vec = new Vector3(1.0, 1.0, 1.0);
    console.log(vec.x);
}

window.onload = main;

I even had a look at RequireJS but I seemed to get more errors (due to me not knowing what is going on)

I also tried the const {Vector3} = require('./mathf/Vector3'); And used module.exports.Vector3 = Vector3 in my Vector3.js file. But require is not defined seeing as it's running the JS on the client side.

Can anyone please point me in the right direction or tell me how I would be able to import the Vector3 class into my test.js code?

.
+-- mathf
|   +-- Vector3.js
+-- node_modules
|   +-- ...
+-- main.html
+-- main.js
+-- package-lock.json
+-- package.json
+-- Test.js

ERR_FILE_NOT_FOUND

<=========== SOLUTION ===========>

The solution was to simply add the following when creating the BrowserWindow()

mainWindow = new BrowserWindow({
        webPreferences:{
            contextIsolation: false,
            nodeIntegration: true,
            nodeIntegrationInWorker: true
        }
    });
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!