Ask coding questions

← Back to all posts
Using .env file in JavaScript
Creatito1 (6)

I tried to use process.env.Right to access the .env file key named Right in my .env file but I got a ReferenceError: process is not defined response, why did this happen and how do I fix it?

Answered by InvisibleOne (2678) [earned 5 cycles]
View Answer
InvisibleOne (2678)

process.env only works in node.js

Creatito1 (6)

@InvisibleOne this is what I saw on the explanation page for .env, so did they just mislabel it or am I missing something?

InvisibleOne (2678)

Yeah, that was for the old Javascript Repls, which I think are now Node.js?
Anyways, if you are trying to do it in an html/css/js repl it won't work, you have to do it in a node.js repl @Creatito1

Creatito1 (6)

@InvisibleOne that's a little disappointing, but thank you!