Dotenv/config path code example
Example 1: node dotenv
require('dotenv').config();
console.log(process.env.MY_ENV_VAR);
Example 2: nodejs dotenv path how to set
const path = require('path')
require('dotenv').config({ path: path.resolve(__dirname, '../../.env') });
Example 3: DOTENV_CONFIG_PATH
"scripts": {
"lint": "tslint --project tsconfig.json",
"build": "tsc",
"prestart": "npm run build",
"prestart:dev": "npm run build",
"prestart:test": "npm run build",
"start": "node -r dotenv/config . dotenv_config_path=./.env",
"start:dev": "node -r dotenv/config . dotenv_config_path=./.env.dev",
"start:test": "node -r dotenv/config . dotenv_config_path=./.env.test",
"test": "echo \"Error: no test specified\" && exit 1"
},