Environment Variable always returns undefined
I'm just trying to import the values from dotenv to the code, but it always returns undefined.
deno version: 1.39.1
running command: deno run --allow-read --allow-env main.ts
dotenv content:
main.ts content:
I also tried
result is always:
Update: also tried
deno run --env --allow-env main.ts
and it still is undefined.14 Replies
Firstly, your
.env
file is formatted incorrectly. It should be FOO=123
.
Secondly, use the —env
CLI argument instead of load()
. I.e. deno run —env main.ts
Oh sorry, I writed it wrongly on the message, actually the file have = instead of :
Still importing dotenv in main.ts?
Deno Blog
Deno 1.38: HTML doc generator and HMR
Deno 1.38 ships with HTML doc output, hot module replacement, improved Node.js compatibility by allowing you to use your own
node_modules
folder, and more.Thankss
somehow, still getting undefined
Are you able to share the repo?
yes, ill put it in github just a sec
not a second lmao but here it is
https://github.com/nogalogg/denotest
GitHub
GitHub - nogalogg/denotest
Contribute to nogalogg/denotest development by creating an account on GitHub.
youre trying to get TEST_TOKEN instead of FOO
omg 😭
LOL! Yes, didn’t see that.
I had a feeling it was a silly typo lol
and.... you're trying to log
test
instead of testgi
oh that i must've writed when i was configuring git to publish it
finally it worked lmaoo
<:deno_it_works:1181937887458111508>
<:deno_thumbs_up:1181937842390319184>
thank you sm