Advanced
dotenvx.parse(src, {processEnv:})
Parse a .env string directly in node.js code without accessing process.env.
Sometimes, you want to run parse
without it accessing process.env
. (You can pass a fake processEnv
this way as well - sometimes useful.)
// index.js
const dotenvx = require('@dotenvx/dotenvx')
const src = 'USER=Me'
const parsed = dotenvx.parse(src, { processEnv: {} })
console.log(`Hello ${parsed.USER}`)
$ node index.js
Hello Me