Avoid using NODE_ENV for staging in Node.js projects

NODE_ENV = staging Well, here we go again - the same old mistake showing up in a new project. In our daily work, we usually have three environments: development, staging and production. We write code locally, run tests, deploy to staging, and if everything looks good - ship to prod. All clear - until you remember that NODE_ENV is not just any variable. It’s a special one used internally by Node.js and many libraries (React, Express, webpack, etc.) to control optimizations and conditional logic. And guess what? It only supports three standard values: "development", "production", and "test". 😀 Anything else (like "staging") can cause warnings - or worse, break something 🤨 . So, if you need to distinguish between staging and production (for example in Airbrake or Langfuse), just use a separate variable, like: APP_ENV=staging Lesson learned (again). #NodeJS #JavaScript #WebDevelopment #SoftwareEngineering #Debugging #DevOps #Backend #EnvironmentVariables #DeveloperNotes #TechTips

To view or add a comment, sign in

Explore content categories