For some reason the behavior of dotenv seems to have changed to require a .env file to exist, which breaks code in environments like Heroku. I'm getting the following when pushing a new Heroku app:
Error: Cannot find module 'dotenv'
Only way around it as far as I can tell it to wrap it in a conditional to only load on development.
Seems to me dotenv should silently fail if no .env exists. Thoughts?
@danawoodman if you pass the silent option that error will not be logged
@danawoodman do you have dotenv in a devDependency that error you getting is that its not installed. This can happen if your NODE_ENV is set to production and dotenv is a dev dependency.
@jcblw that was it! Had it as a devDependency without realizing it. Thanks! :+1:
@maxbeatty thanks for the heads up about output!
Most helpful comment
@danawoodman do you have
dotenvin a devDependency that error you getting is that its not installed. This can happen if yourNODE_ENVis set toproductionanddotenvis a dev dependency.