A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/motdotla/dotenv/issues/133 below:

Using with ES6 modules · Issue #133 · motdotla/dotenv · GitHub

In the case of using ES6 modules via import, configuring dotenv in the base file doesn't set the environment vars in sub-modules. For example:

index.js
import dotenv from 'dotenv'
dotenv.config({ silent: true })
import hello from './hello'
hello.js
console.log(process.env) /* this doesn't have the environment vars in it */

This is because babel compiles the above as

var dotenv = require('dotenv')
var hello = require('./hello')
dotenv.config({ silent: true })

It works if I do import 'dotenv/config' instead, but then I can't specify the silent flag, so it throws an error if .env doesn't exist (for example, if running in production). I think a simple solution would be to allow something such as import 'dotenv/register' for a one-line, silent setup of the variables.

gbertoncelli, superboy93, dreamyguy and ianchanning


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4