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

714
Views
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 answers
Answer question

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 Report
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!