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

348
Vistas
Electron: require() of ES Module

I'm trying to make a simple app for the first time, However I keep getting this error whenever I try to import any npm package. I'm unsure of what I did wrong because I'm using the npm package electron-reload and that's not throwing any errors.

ERROR: require() of ES Module

This is my tsconfig.json:

{
  "compilerOptions": {
    "target": "ES5",                                 
    "module": "CommonJS",                              
    "outDir": "./app/js/",                                   
    "esModuleInterop": true,                             
    "forceConsistentCasingInFileNames": true,
    "strict": true,                                      
    "skipLibCheck": true,                                
  },
  "exclude": ["./app/js/**/*.js"],
  "compileOnSave": true
}

This is the code in which the error is being thrown:

import Hwid from "hwid";

ipcMain.on("get-hwid", (event) => {
    console.log(Hwid());
});

And lastly, this is my BroswerWindow code:

const window = new BrowserWindow({
        width: 700,
        frame: false,
        height: 700,
        resizable: false,
        transparent: true,
        roundedCorners: true,
        icon: path.join(__dirname, "../design/imgs/dully_logo.png"),
        webPreferences: {
            contextIsolation: false,
            nodeIntegration: true,
            preload: path.join(__dirname, "preload.js"),
            devTools: false,
        },
    });
    window.loadFile(path.join(__dirname, "../design/index.html"));

I'm using TypeScript because I prefer it more than regular JS, I'm just stuck on what to do or why this error stops my development. I'm expecting the package to run like normal, yet nothing works.

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

hwid is an ESM module and your tsconfig.json specifies to write modules using CommonJS, which is the require() function. tsc (or other compilers) converts your import statements to require() calls, which is not permitted with ESM (as the error says). Either use an older version of hwid which may support ESM or change module to 'es2020' and set moduleResolution to 'node'.

about 4 years ago · Juan Pablo Isaza Denunciar

0

Try: const Hwid = require('hwid')

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