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

415
Views
Electron - Failed to load resource: net::ERR_FILE_NOT_FOUND

relatively new to electron area:

I tried a few method to solve this issue such as using ./ instead of / or adding "homepage" : in packaging.json and still won't work.

I was trying to import these two

<script src="node_modules/gridstack/dist/gridstack-h5.js"></script>
<link href="node_modules/gridstack/dist/gridstack.min.css" rel="stylesheet"/>

my json:

{
  "name": "login",
  "version": "1.0.0",
  "homepage":"./",
  "main": "main.js",
   ....
}

html:

<!DOCTYPE html>
  <head>
    <title>Infomation Board </title>
    <link rel="stylesheet" href="../styles/styles.css" />
    <script src="node_modules/gridstack/dist/gridstack-h5.js"></script>
    <link href="node_modules/gridstack/dist/gridstack.min.css" rel="stylesheet"/>
  </head>
  <body>
  ...
  ..

And when I run debug, I get either of these errors:

GET file:///C:/node_modules/gridstack/dist/gridstack-h5.js net::ERR_FILE_NOT_FOUND

 GETfile:///C:/Users/whatd/OneDrive/Desktop/Amazon%20Verson%202/src/directories/node_modules/gridstack/dist/gridstack.min.css net::ERR_FILE_NOT_FOUND

directory:

directory

how would I go about solving this issue?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I think the "homepage": line in your package.json file is a React thing. If you are not using React then you can remove the "homepage": line.

The "main": line in your package.json file is the entry point of your Electron app. Therefore, if the js file that will kick things off is "main.js" then "main": "main.js" is correct.

package.json

{
  "name": "login",
  "version": "1.0.0",
  "main": "main.js",
  ...
}

If you are creating your info-board window in your main.js file then you would do so like this.

main.js

// Electron module(s).
const electronApp = require('electron').app;
const electronBrowserWindow = require('electron').BrowserWindow;

// Node module(s).
const nodePath = require('path');

// Declare window (no garbage collect).
let infoBoardWindow;

// Application is now ready to start.
electronApp.on('ready', () => {

  // Create the info-board window.
  infoBoardWindow = new electronBrowserWindow({
    x: 0,
    y: 0,
    width: 800,
    height: 600,
    show: false,
    webPreferences: { 
      nodeIntegration: false,
      contextIsolation: true,
      worldSafeExecuteJavaScript: true,
      enableRemoteModule: false,
      preload: nodePath.join(__dirname, 'preload.js')
    }
  });

  // Load the info-board window.
  infoBoardWindow.loadFile(nodePath.join(__dirname, './src/directories/infoboard.html'))
  .then(() => { infoBoardWindow.show(); })
});

Now, to reference both the gridstack css and js files in your infoboard.html file use relative paths (./, ../), not an absolute path (/). IE: You need to step-up 2 directory levels to get access to the node_modules directory.

infoboard.html

<!DOCTYPE html>
  <head>
    <title>Infomation Board </title>
    <link rel="stylesheet" href="../styles/styles.css" />
    <link rel="stylesheet" href="../../node_modules/gridstack/dist/gridstack.min.css" />
    <script src="../../node_modules/gridstack/dist/gridstack-h5.js"></script>
  </head>
  <body>
  ...
  ..
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!