Closed tymfear closed 3 years ago
config
doesn’t export to to Deno.env
by default. But you can pass a flag to enable that. Also be sure to call config before trying to access the variable via Deno.env
.
import { config } from "https://deno.land/x/dotenv@v2.0.0/mod.ts";
console.log(config({ export: true }));
console.log(Deno.env.get("HELLOWORLD"));
alternatively you can auto load the variables into Deno.env: https://github.com/pietvanzoen/deno-dotenv#auto-loading
// app.ts
import "https://deno.land/x/dotenv/load.ts";
console.log(Deno.env.get("GREETING"));
I hope this helps. Let me know how you get on. :)
@pietvanzoen , that helped, thanks! Haven't seen the difference in import URL for load
and config
.
deno --version output
.env file
testenv.ts
output of
deno run -A testenv.ts
Though it loads it to the
config
method output