-
Notifications
You must be signed in to change notification settings - Fork 27.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NODE_ENV=development next build fails on static 404 and 500 pages #25491
Comments
Related to #19046. Currently, Next relies upon |
Thanks. The related warn link below was never shown, probably a good idea to show it to guide the users: |
I found some time to dive into the source and Next is only checking for non-standard So... since you're trying to import Envs based upon Click to expand alternative solutionI've developed a package for loading Envs called @noshot/env, which I have been using for my personal and professional projects for the past 7 months. This package operates similar to dotenv/dotenv-config -- which is what @next/env uses; however, my package is a bit more optimized and, more importantly, flexible. 1.) Install the package: 2.) Create an env.config.json file in your projects root directory and add paths properties for environments. These paths refer to the env.config.json (for a complete list of allowed properties see config arguments) {
"development": {
"paths": [".env", ".env.development", ".env.local", ".env.development.local"],
"debug": true
},
"staging": {
"paths": [".env.staging"],
"debug": true
}
} 3.) Then. utilize LOAD_CONFIG with script preloading to load a specific configuration according to the specified environment: package.json {
"scripts": {
"dev": "LOAD_CONFIG=development NODE_OPTIONS='-r @noshot/env' next dev",
"staging": "LOAD_CONFIG=staging NODE_OPTIONS='-r @noshot/env' next build"
},
"dependencies": {
"snackables": "^3.x.x"
}
} And that's it. The package will load the There's only one potential catch: Next will still attempt to load the standard If you're not interested in using the alternative solution, then you should submit an RFC for controlling how/which |
I'm also having this bug. I've opened an RFC for a proper solution here: #25764 |
Could not reproduce this. |
This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
What version of Next.js are you using?
10.2.3
What version of Node.js are you using?
14+
What browser are you using?
Chrome
What operating system are you using?
macOs
How are you deploying your application?
next start
Describe the Bug
After updating from 10.1.3 to 10.2.3 and script execution
NODE_ENV=development npm run build (=> next build)
the following error appears:When executing the same script with
NODE_ENV=production npm run build
everything works as expected.Downgrading next to 10.1.3 resolves the issue.
Why do I need to set NODE_ENV? Several configuration options depend on the NODE_ENV. For exmaple in
development
a different backend url and DB is being accessed etc.Expected Behavior
NODE_ENV=development next build
works as it did in 10.1.3To Reproduce
NODE_ENV=development next build
Building static 404 and 500 pages fails...
The text was updated successfully, but these errors were encountered: