I am referring to the NODE_ENV environment variable to enable some debugging features on the node.js server. It worked like a charm, but now I come across some very strange things. That's what I'm doing:
// check if the env var is OK console.log(process.env.NODE_ENV); // WTF??? if (process.env.NODE_ENV == "development") { console.log("ok"); } else { console.log("nope"); } // sanity check var str = "development"; if (str == "development") { console.log("ok"); } else { console.log("nope"); }
And here is what I get:
development nope ok
How is this possible? Am I encountering an error in node.js? If not, what am I doing wrong?
EDIT
The following noteworthy comment below is what I get if I change my original log to console.log("[" + process.env.NODE_ENV + "]"); :
]development nope ok
So a known problem?
Laurent couvidou
source share