Skip to content

process.env is always undefined in production #87

Answered by rphlmr
rodolphoasb asked this question in Q&A
Discussion options

You must be logged in to vote

Hello 👋
Is it happening on the production build?
According to the trace, I would say yes.

I think you have to pass your environment variables before executing the start command or set them according to your hosting provider's recommendations.

DATABASE_HOST=xxx npm run start

Dotenv is only used in development mode. However, if you want to load an .env file, add it to the build/server folder, close to your index.js because configDotenv may expect to resolve the file relative to that location.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by rodolphoasb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants