I should only need to do:
import dotenv from "dotenv";
dotenv.config();
in the index.js file. But my .env
variables only work when I explicitly import and configure dotenv in each file that uses .env variables.
This is my tsconfig.json
:
{
"compilerOptions": {
"rootDirs": ["src"],
"baseUrl": "./src",
"outDir": "dist",
"lib": ["es2020"],
"target": "es2020",
"module": "esnext",
"moduleResolution": "node",
"allowJs": true,
"esModuleInterop": true,
"types": ["node"]
},
}
Not sure why, any ideas?