Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

141
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda