Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

144
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda