diff --git a/README.md b/README.md
index 034fc52d..10d4376f 100644
--- a/README.md
+++ b/README.md
@@ -65,6 +65,9 @@ The configuration options below are supported as command line arguments in the f
$ node -r dotenv/config your_script.js dotenv_config_path=/custom/path/to/your/env/vars
```
+If you are having trouble passing the `dotenv_config_=value` part via the CLI, you can use environment variables instead. When using environment variables, be sure to use uppercase names, `DOTENV_CONFIG_ =value`.
+
+
## Config
_Alias: `load`_
diff --git a/config.js b/config.js
index 77641220..db4a6926 100644
--- a/config.js
+++ b/config.js
@@ -2,6 +2,6 @@
(function () {
require('./lib/main').config(
- require('./lib/cli-options')(process.argv)
+ Object.assign({}, require('./lib/env-options')(process.env), require('./lib/cli-options')(process.argv))
)
})()
diff --git a/lib/env-options.js b/lib/env-options.js
new file mode 100644
index 00000000..d09d58a0
--- /dev/null
+++ b/lib/env-options.js
@@ -0,0 +1,9 @@
+/* @flow */
+
+module.exports = function (env = {}) {
+ return Object.assign({},
+ env.DOTENV_CONFIG_ENCODING ? { encoding: env.DOTENV_CONFIG_ENCODING } : null,
+ env.DOTENV_CONFIG_PATH ? { path: env.DOTENV_CONFIG_PATH } : null,
+ env.DOTENV_CONFIG_DEBUG ? { debug: env.DOTENV_CONFIG_DEBUG } : null
+ )
+}
diff --git a/tests/test-env-options.js b/tests/test-env-options.js
new file mode 100644
index 00000000..e0390d60
--- /dev/null
+++ b/tests/test-env-options.js
@@ -0,0 +1,29 @@
+/* @flow */
+
+const t = require('tap')
+
+const options = require('../lib/env-options')
+
+t.plan(6)
+
+// matches encoding option
+t.same(options({ DOTENV_CONFIG_ENCODING: 'utf8' }), {
+ encoding: 'utf8'
+})
+
+// matches path option
+t.same(options({ DOTENV_CONFIG_PATH: '/custom/path/to/your/env/vars' }), {
+ path: '/custom/path/to/your/env/vars'
+})
+
+// matches debug option
+t.same(options({ DOTENV_CONFIG_DEBUG: 'true' }), {
+ debug: 'true'
+})
+
+// ignores empty values
+t.same(options(), {})
+t.same(options({}), {})
+
+// ignores unsupported options
+t.same(options({ DOTENV_CONFIG_FOO: 'foo' }), {})