UPDATE 2022-11-23:
See how-to-set-environment-variables-from-within-package-json.
In short:
"start:dev": "NODE_ENV=development next start"
You might need cross-env (on Windows ? I don’t know):
"start:dev": "cross-env NODE_ENV=development next start"
More specific documentation is now available (and maybe requirements also have changed, or maybe not):
environment-variable-load-order:
… Note: The allowed values for NODE_ENV are production, development and test.
non-standard-node-env:
… only permitting three (3) values:
- production: When your application is built with next build
- development: When your application is ran with next dev
- test: When your application is being tested (e.g. jest)
ORIGINAL ANSWER:
See issue #9123, (Oct 18, 2019) :
NODE_ENV is a reserved environment variable that cannot be changed.
The only valid values are production, development, and test.If you need your app behavior to change in different production
environments, please use a different variable like APP_ENV.
And issues #17032 (Sep 12, 2020):
process.env.NODE_ENVonly has 2 possible valuesdevelopmentand
production. If this is not set to that value you’ll run into all kinds
of library edge cases (especially in node_modules) where you get
severely de-optimized results. E.g. if you run a performance test
you’ll get significantly worse results ifprocess.env.NODE_ENVis not
set to production