NODE_ENV
noun
say it: “NOHD EN-vee” /noʊd ˈɛnvi/
An environment variable that tells a Node program whether it is running in development, testing or production.
What is NODE_ENV?
NODE_ENV is an environment variable that says where Node code is running: usually development, test or production. Express and many packages read it, for example to hide error details from users in production.
const isProduction = process.env.NODE_ENV === "production";
console.log(isProduction ? "Live site" : "On my laptop");
In a sentence
- “On the host, NODE_ENV is production, so error answers show no stack traces.”
- “The tests set NODE_ENV to test, which turns off the request logs.”
Level: Apprentice · More Node.js terms at this level
Updated