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

339
Vistas
Replacing JS require('...') with ESM imports

After updating node-fetch to v3, the following JavaScript error message appears when trying to launch my Electron app:

Uncaught Exception: Error [ERR_REQUIRE_ESM]: require() of ES Module (...) not supported. Instead change the required ... to a dynamic import() ...

I have found here that I should replace

const fs = require('fs');

with:

import fs from "fs";

But how to replace in the same fashion the following?

// Modules to control application life and create native browser window
const {
  app,
  session,
  BrowserWindow
} = require('electron');
about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

Typically, you would do this as you have done it with fs and would do with other ES modules:

import { app, session, BrowserWindow } from "electron";

However, I don't believe you can do this directly with Electron as it's a CommonJS module and not all the modules are directly named as exports.

You should be able to import what you need via the default import however:

import electron from "electron";
const { app, session, BrowserWindow } = electron;
about 4 years ago · Juan Pablo Isaza Denunciar

0

U need replace package name with variable or functions with brackets around them

import { app, session, BrowserWindow } from "electron";

This will work for sure

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