How to get environment configuration from nx workspace from express


In my nx-workspace it has 2 environment.ts files as environment.ts and

I am trying to get the base url of environment.ts. (which is development) but i could not able to get. what is the correct way to get it?

my try for console:

const server = app.listen(port, () => {
  console.log(process.env.MONGO_URL); //undefined
  console.log('Listening at http://localhost:' + port + '/api');

environment.ts file:

export const environment = {
  production: false,

so what is the correct way to get the current env values?


I just imported the environment file, it woks fine.

import { environment } from './environments/environment';

const server = app.listen(port, () => {
  console.log('Listening at http://localhost:' + port + '/api');

Answered By – 3gwebtrain

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published