chihab / dotenv-run

Seamlessly load environment variables. Supports cli, esbuild, rollup, vite, webpack, angular. ESM and Monorepos.
238 stars 17 forks source link

environment variables not being set #55

Closed scry-UrjitDesai closed 1 year ago

scry-UrjitDesai commented 1 year ago

Hey, I am trying to use the library for something i am working on. I followed the steps listed but I cannot access the .env files and variables inside them. I tried to log the import.meta.env it says {NG_APP_ENV: undefined}

I used: ng serve which prints the following.

I have my .env file at the package.json level here are its contents:

SERVER_URL=http://google.com NUMBER_OF_FILES=10

I want to access them within my code but it gives me undefined.

chihab commented 1 year ago

Hey, you should use NG_APP prefix, so NG_APP_SERVER_URL and NG_APP_NUMBER_OF_FILES.

scry-UrjitDesai commented 1 year ago

Thanks, that solved it !