Requerir (dotenv). config () typeScript
import dotenv from 'dotenv';
dotenv.config();
export const YOUR_ATTRIBUTE = process.env.YOUR_ATTRIBUTE!;
DevPedrada
import dotenv from 'dotenv';
dotenv.config();
export const YOUR_ATTRIBUTE = process.env.YOUR_ATTRIBUTE!;
import dotenv from 'dotenv';
dotenv.config();
console.log(process.env.MY_KEY);
npm install dotenv;
OR
yarn add dotenv;
import * as dotenv from 'dotenv';
//inside your starter code, do this
...
...
dotenv.config();
...
// when yours .env is in other place then default, you can set path to it
const path = require('path')
require('dotenv').config({ path: path.resolve(__dirname, '../../.env') }); //use as many '../' as you need
import 'dotenv/config'
dotenv ts