-1

My project structure look like this:

|-project
   |-src
     |-index.ts
   |-.env

in index.ts I'm trying to load environment variables:

import dotenv from 'dotenv';
dotenv.config();

I've also tried with

dotenv.config({
    path: __dirname+"/../.env"
});

file .env itself is surely ok, where is the mistake? Thank for help

command that I'm running is ts-node ./src/index.ts

edit: I'm accesing values using expression like process.env.DB_CONNECT

.env file

DB_CONNECT=someValue
TOKEN_KEY=someValue
woda
  • 107
  • 1
  • 5

2 Answers2

1

Can you try this?

import { resolve } from 'path';
import dotenv from 'dotenv';
dotenv.config({ path: resolve(__dirname, "../.env") });
-1

nevermind, it was my bad implementation of default values in functions. closing

woda
  • 107
  • 1
  • 5