The source code for this blog is available on GitHub.
Note
Top

Hock Vercel

Cover Image for Hock Vercel
Han Chen
Han Chen

Vercel

NODE_ENV

NODE_ENV is a common environment variable in Node.js applications that allows you to set the current mode or environment in which your application is running. It is typically used to specify whether the application is running in 'development', 'testing', or 'production' mode.

When deploying applications using Vercel, there are three types of deployment environments that Vercel recognizes: Production, Preview, and Development.

As of my knowledge cutoff in September 2021, the NODE_ENV value is automatically set to 'production' for both Production and Preview deployments on Vercel. This is because both of these environments are designed for deploying live, user-facing code. The difference between them is that Production deployments are associated with the 'production' branch (usually main or master), while Preview deployments are associated with all other branches and are intended for testing and review purposes before the final deployment.

So, even though it's a Preview deployment, it's still meant to closely simulate the Production environment, and as such, NODE_ENV is set to 'production'.

This behavior is defined by Vercel's platform and isn't something you would generally control. If you want to differentiate between Preview and Production deployments in your code, you can use the VERCEL_ENV environment variable, which will be set to 'production', 'preview', or 'development' based on the type of deployment.

It's important to note that this information might have changed if Vercel updated their platform policies or behavior after my last training data in September 2021. You may want to check Vercel's current documentation or reach out to their support for the most up-to-date information.

© 2024 WOOTHINK. All Rights Reserved.
Site MapTerms and ConditionsPrivacy PolicyCookie Policy