-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
Unable to change NODE_ENV manually #617
Comments
Hmmm... that is true, we set somewhere in code NODE_ENV to production during build — but you kinda have to have it that way — there's all sorts of optimizations within React and other modules within the React ecosystem that are only turned on when Why not just set another env variable e.g. |
Yeah I also tried custom variables though bash but logging |
Any news on this? Can't seem to set any custom variables, e.g.: For those in a similar circumstance, my current workaround is to create a environment js file that changes depending on environment (in Gatsby's case, build task).
|
Closing this for #660 |
For reference, this issue is related to #337 (comment)
|
So we can't override NODE_ENV? I wanted to set NODE_ENV to staging so gatbsy uses |
We work around this in // gatsby-config.js
let activeEnv = process.env.ACTIVE_ENV
if (!activeEnv) {
activeEnv = 'development'
}
require('dotenv').config({
path: `.env.${activeEnv}`,
}) In our CI pipeline we set
|
@jongear i get this error according to your workaround (same as in gatsby docs) and tried to install dependencies , but without succes:
|
Looking at this PR, it looks like you should be able to edit the NODE_ENV. This works for develop but the build command always overwrites to "production"
Testing with
NODE_ENV=foo npm run build
. With the package json script being the default"build": "gatsby build"
The text was updated successfully, but these errors were encountered: