backend: Ignore if .env file cannot be found

fix: #7
This commit is contained in:
roschaefer 2020-06-05 16:29:13 +02:00
parent 92fba41286
commit 063200bcb1

View File

@ -1,7 +1,12 @@
import dotenv from 'dotenv'
if (require.resolve) {
// are we in a nodejs environment?
dotenv.config({ path: require.resolve('../../.env') })
try {
dotenv.config({ path: require.resolve('../../.env') })
} catch (error) {
if (error.code !== 'MODULE_NOT_FOUND') throw error
console.log('WARN: No `.env` file found in /backend') // eslint-disable-line no-console
}
}
// eslint-disable-next-line no-undef