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

156
Vistas
How to import JavaScript file withnot dot js in node

I'm working on NodeJs project

This is not working

import Env from "./utils/Env";

Error [ERR_MODULE_NOT_FOUND]: Cannot find module ...\Env

This is my Env.js code

export default class Env {
  static isLocal() {
    return !(process.env.NODE_ENV === 'production');
  }
  static isProd() {
    if (process.env.NODE_ENV === 'production' && process.env.GCLOUD_PROJECT === 'extendedbuilder') {
        return true;
    }
    return false;
  }
}

But if I add .js, then works

import Env from "./utils/Env.js";

Is there any way for ignoring the ".js" when I'm importing the module?

Thank you

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

0

This thread has a example that can solve your problem - https://stackoverflow.com/a/34967457/17289563

See export syntax on MDN - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/export

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