-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Starting or Building Keystone with NODE_ENV set production fails. #8774
Comments
I just downgraded to |
Had the same, removed node_env from my .env and building was fine. Cryptical, and is manually setting node_env really that evil? |
If you set it to any value other than production. it will build successfully. But why is setting it to production a problem? |
Cannot reproduce this, and you should always have |
The only other information missing from what I already provided is that I'm working on Ubuntu 22.04. I can make a loom showing everything I did step by step. Noticed this because it failed during image build on the CI with |
@dcousens I checked this and I can reproduce it. The key is to import @chukwumaijem if this is blocker for you (you use NODE_ENV checks for some other code), try adding NODE_ENV in the package.json script commands - |
Thank you @marekryb. It builds successfully when I set NODE_ENV in the build script. |
This aligns with the
|
That's exactly what I was doing. See the screenshot attached. Or the loom. But it was causing an error. |
Interesting, I think we should keep this open |
I'm getting the same issue - created an issue before I found this one |
@dcousens It only works in npm scripts as per suggestion above, having it set in a .env file doesn't work. I don't know the underlying code, probably a separate discussion, but I do wonder if |
Thanks @dcousens that sounds fantastic |
@dcousens
Notice how initially node is using .dev.js bundle and later it is switching to .prod.js bundle. So here is what I believe is happening:
Additional (surprising) takeaway: |
Thanks for the detailed description @marekryb, hopefully we can reduce the complexity of this through some parallel improvements and then come back to thinking about how we can stop this from happening. Using |
Please add steps to reproduce the problem
keysone.ts
file, import dotenvimport 'dotenv/config';
NODE_ENV=production
in .env filePlease describe what you expected to happen
It should build successfully. It builds in development, testing, and staging. It builds even when NODE_ENV is undefined. But only fails in production mode.
Please add any screenshots if possible
Please add contextual information such as your node version (node -v), or the web browser you used
Tried on NODE v16, v18, and v20 (using nvm).
The text was updated successfully, but these errors were encountered: