process.env.NODE_ENV
The NODE_ENV environment variable (process.env.NODE_ENV) is a widespread convention used by tools to distinguish between development and production environments.
In development, make sure process.env.NODE_ENV is one of:
// In development:
process.env.NODE_ENV === 'development' // ✅
process.env.NODE_ENV === 'dev' // ✅
process.env.NODE_ENV === '' // ✅
process.env.NODE_ENV === undefined // ✅In production, it should be any other value.
It's important to respect this convention: many tools run erroneously otherwise.
You can run
$ NODE_ENV='production' node server/index.jsto set a correctNODE_ENVvalue for production.During build (
$ vike buildand$ vike prerender), theprocess.env.NODE_ENVvalue is automatically set to'production'.
See also
- Node.js Docs - The difference between development and production
While the
process.env.NODE_ENVconvention was introduced by Node.js, it's used by tools regardless of whether you use Node.js. Thus, make sure to follow the convention even in non-Node.js environments. - Stack Overflow - What is NODE_ENV and how to use it in Express?
- ❌ Wrong setup