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

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

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