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

715
Visualizações
Failed to load resource (file not found) Electron js cannot import or export

Failed to load resource: net::ERR_FILE_NOT_FOUND

I am using latest version of npm, node.js and electron.

My html file calls upon a terrautils.js:

<script type="module" src="./terrautils.js"></script>

My terrautils.js file has first line as:

import { LCDClient, Coin } from './node_modules/@terra-money/terra.js';

Which is the link to an npm module that I want to use, and I have it installed and have confirmed that the folder is really there using file explorer. I also know the module works perfectly file, because this issue only happens when I run using npm start but when I run using node terrautils.js and swap from using import to using require, it works perfectly fine.

This is something to do with electron I think, and not sure what to do. My main.js has createWindow function like:

function createWindow (site) {
  var win = new BrowserWindow({
    width: 700,
    height: 600,
    webPreferences: {
      preload: path.join(__dirname, 'preload.js'),
      nodeIntegration: true,
      contextIsolation: true,
      devTools: true,
    }
  })

  win.loadFile(site)
}

I do not care about security, I just want this to work. Thank you.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Solution:

Change html invoking of the js file to this instead:

    <script>
        require('./terrautils.js')
    </script>

dont know how it works, but it does.

about 4 years ago · Juan Pablo Isaza Relatório
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