Dotenv: Dotenv doesn't work when .env is missing?

Created on 12 May 2015  路  3Comments  路  Source: motdotla/dotenv

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?

Most helpful comment

@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.

All 3 comments

@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!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

samayo picture samayo  路  3Comments

AndrewChen1982 picture AndrewChen1982  路  4Comments

awesomejerry picture awesomejerry  路  4Comments

shellscape picture shellscape  路  3Comments

goldbergyoni picture goldbergyoni  路  3Comments