Can't read variable from file .env in nx workspace

327 Views Asked by At

I have been tried to build a node app with nx workspace, however, the contents of the variable in the .env file cannot be read. I run this node app with this command:

node dist/apps/bot/main.js

I tried to debug the variable. here my code:

import 'dotenv';
import { Telegraf } from 'telegraf';
import { environment } from './environments/environment';
import { App } from './app/app';

const x = process.env.TOKEN;
const bot = new Telegraf(environment.token);

(async () => {
  console.debug('Start bot ....');
  console.log(x);
  const start = await App(bot);
  start.launch();
})();

and this is the result: enter image description here

has anyone ever experienced something similar like that? thankyou

0

There are 0 best solutions below