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