It works locally, but throws a 500 as soon as I deploy
I was trying to deploy a side project over the weekend, but something that ran fine locally throws a 500 as soon as I put it on the server lol
The logs say it’s an environment variable issue, but I definitely added the .env file. I’ll have to take another look tomorrow. Dev really feels like a different game between local and production.
9 answers
Agreed—trusting only local and wasting the whole weekend is just the unwritten rule lol
If it still doesn't work even after adding .env, there's a high chance it's a load order or path issue. Could your dotenv.config() call be placed after the import(s)?
Well, it's a bit of a stretch to conclude it's an 'environment variable issue' from the logs alone. Maybe you should post the full 500 stack trace if you want people to help?
There are also many cases where devDependencies aren't installed because NODE_ENV=production. Take a look at your build script.
Same here ㅠ I was stuck on just this all day yesterday