{"name":"dotenv-expand","version":"13.0.0","keywords":["dotenv","expand","variables","interpolation","substitution","env",".env"],"author":{"name":"motdotla"},"license":"BSD-2-Clause","_id":"dotenv-expand@13.0.0","maintainers":[{"name":"motdotla","email":"mot@mot.la"}],"homepage":"https://github.com/motdotla/dotenv-expand#readme","bugs":{"url":"https://github.com/motdotla/dotenv-expand/issues"},"dist":{"shasum":"e3bb68c3c1b59b015cda83d9a64efed6bb52242b","tarball":"http://registry-npm.ywwl.com/dotenv-expand/download/dotenv-expand-13.0.0.tgz","fileCount":8,"integrity":"sha512-aBfBS8eYIeXmpHI9ThIlA7/WLq+SLt18iXUZhb52rW89QLKQFoIpPG1bPeewoPZsTyjSSO3T7234FBVUM1V2rA==","signatures":[{"sig":"MEYCIQCs5sR8IgrbPXnCEfVSCxPWDfFGrsUEDQ8XHIkx52eVMQIhAKJETloPgXQ3gBwwIGun8+1c9nlLWzao3wswjRFw9WB0","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":19045,"size":6914,"noattachment":false,"key":"/dotenv-expand/-/dotenv-expand-13.0.0.tgz"},"main":"lib/main.js","types":"lib/main.d.ts","engines":{"node":">=12"},"exports":{".":{"types":"./lib/main.d.ts","default":"./lib/main.js","require":"./lib/main.js"},"./config":"./config.js","./config.js":"./config.js","./package.json":"./package.json"},"funding":"https://dotenvx.com","gitHead":"53e18d4216e8902b58c2421393331e5c9af34bc3","scripts":{"lint":"standard","test":"tap tests/*.js --100 -Rspec","pretest":"npm run lint && npm run dts-check","release":"standard-version","dts-check":"tsc --project tests/types/tsconfig.json","prerelease":"npm test","test:coverage":"tap --coverage-report=lcov"},"_npmUser":{"name":"motdotla","email":"mot@mot.la"},"repository":{"url":"git+https://github.com/motdotla/dotenv-expand.git","type":"git"},"_npmVersion":"11.6.2","description":"Expand environment variables using dotenv","directories":{},"_nodeVersion":"23.4.0","dependencies":{"dotenv":"^17.4.2"},"_hasShrinkwrap":false,"devDependencies":{"tap":"^16.3.0","standard":"^16.0.4","typescript":"^4.5.4","@types/node":"^18.11.3","standard-version":"^9.5.0"},"_npmOperationalInternal":{"tmp":"tmp/dotenv-expand_13.0.0_1776462641205_0.5861857112845774","host":"s3://npm-registry-packages-npm-production"},"readme":"> If you have found dotenv-expand useful, consider checking out [dotenvx](https://github.com/dotenvx/dotenvx) for encrypting your `.env` files. Thank you for using dotenv. 🙏\n\n# dotenv-expand [![NPM version](https://img.shields.io/npm/v/dotenv-expand.svg?style=flat-square)](https://www.npmjs.com/package/dotenv-expand) [![downloads](https://img.shields.io/npm/dw/dotenv-expand)](https://www.npmjs.com/package/dotenv-expand)\n\n<img src=\"https://raw.githubusercontent.com/motdotla/dotenv/master/dotenv.svg\" alt=\"dotenv\" align=\"right\" width=\"200\" />\n\nDotenv-expand is a zero-dependency module that adds variable expansion, command substitution, and encrypted value support on top of [dotenv](https://github.com/motdotla/dotenv).\n\n&nbsp;\n\n## Usage\n\nInstall it alongside dotenv.\n\n```sh\nnpm install dotenv dotenv-expand --save\n```\n\nCreate a `.env` file in the root of your project:\n\n```ini\n# .env\nUSERNAME=\"dotenv\"\nDATABASE_URL=\"postgres://${USERNAME}@localhost/my_database\"\n```\n\nAs early as possible in your application, configure dotenv and expand its result:\n\n```javascript\n// index.js\nconst dotenv = require('dotenv')\nconst dotenvExpand = require('dotenv-expand')\n\ndotenvExpand.expand(dotenv.config())\n\nconsole.log(process.env.DATABASE_URL)\n```\n\n```sh\n$ node index.js\npostgres://dotenv@localhost/my_database\n```\n\nThat's it. `process.env` now contains the expanded values from your `.env` file.\n\n&nbsp;\n\n## Advanced\n\n<details><summary>Preload</summary><br>\n\n> Consider using [dotenvx](https://github.com/dotenvx/dotenvx) instead. It includes expansion, command substitution, and encrypted `.env` support across languages and platforms:\n>\n> ```sh\n> dotenvx run -- node your_script.js\n> ```\n\nUse Node's `--require` (`-r`) option to load and expand `.env` before your application starts:\n\n```sh\nnode -r dotenv-expand/config your_script.js\n```\n\nThe preload entry is self-contained; you do not need to separately install dotenv.\n\nConfiguration options can be passed as command-line arguments:\n\n```sh\nnode -r dotenv-expand/config your_script.js dotenv_config_path=/custom/path/to/.env\n```\n\nOr as environment variables:\n\n```sh\nDOTENV_CONFIG_ENCODING=latin1 node -r dotenv-expand/config your_script.js\n```\n\nCommand-line arguments take precedence over environment variables.\n\n</details>\n\n<details><summary>pnpm</summary><br>\n\n```sh\npnpm add dotenv dotenv-expand\n```\n\n</details>\n\n<details><summary>Command Substitution</summary><br>\n\nUse `$(command)` to replace an expression with the command's output:\n\n```ini\nNODE_VERSION=$(node --version)\n```\n\nOnly use command substitution with `.env` files you trust. Commands run with the permissions of the current process.\n\n</details>\n\n<details><summary>Encrypted Values</summary><br>\n\nUse [dotenvx](https://dotenvx.com) to encrypt your `.env` file. dotenv-expand automatically decrypts `encrypted:` values when `DOTENV_PRIVATE_KEY` is set:\n\n```sh\nDOTENV_PRIVATE_KEY=\"<private key>\" node -r dotenv-expand/config your_script.js\n```\n\nKeep the private key separate from the encrypted `.env` file—for example, in your cloud platform's secrets manager. Read the [dotenvx whitepaper](https://dotenvx.com/dotenvx.pdf?v=README) for more details.\n\n</details>\n\n<details><summary>Custom Process Environment</summary><br>\n\nUse `processEnv` to write expanded values to an object other than `process.env`:\n\n```javascript\nconst dotenvExpand = require('dotenv-expand')\n\nconst myEnv = {}\n\ndotenvExpand.expand({\n  processEnv: myEnv,\n  parsed: {\n    HELLO: 'World'\n  }\n})\n\nconsole.log(myEnv.HELLO) // World\nconsole.log(process.env.HELLO) // undefined\n```\n\n</details>\n\n<details><summary>Interpolation Syntax</summary><br>\n\ndotenv-expand supports braced and unbraced expansion, default values, and alternate values:\n\n```ini\nBASIC=\"basic\"\nBRACED=${BASIC}\nUNBRACED=$BASIC\nDEFAULT=${MISSING:-default}\nALTERNATE=${BASIC:+alternate}\n```\n\nSee the complete [interpolation rules](https://dotenvx.com/docs/env-file#interpolation).\n\n</details>\n\n&nbsp;\n\n## FAQ\n\n<details><summary>What rules does the expansion engine follow?</summary><br>\n\nSee a full list of rules [here](https://dotenvx.com/docs/env-file#interpolation).\n\n</details>\n\n<details><summary>How does command substitution work?</summary><br>\n\nUse `$(command)` in your `.env` file. dotenv-expand runs the command and replaces the expression with its output. See the Command Substitution example under Advanced.\n\n</details>\n\n<details><summary>How does encryption work?</summary><br>\n\nUse [dotenvx](https://dotenvx.com) to encrypt your `.env` file. dotenv-expand automatically decrypts `encrypted:` values when `DOTENV_PRIVATE_KEY` is set.\n\n```sh\nDOTENV_PRIVATE_KEY=\"<private key>\" node -r dotenv-expand/config your_script.js\n```\n\nKeep the private key separate from the encrypted `.env` file—for example, in your cloud platform's secrets manager. Read the [dotenvx whitepaper](https://dotenvx.com/dotenvx.pdf?v=README) for more details.\n\n</details>\n\n<details><summary>Is it safe to commit an encrypted `.env` file?</summary><br>\n\nYes, as long as the corresponding `DOTENV_PRIVATE_KEY` is stored separately and never committed with it. Use [dotenvx](https://dotenvx.com) to create and manage the encrypted file.\n\n</details>\n\n<details><summary>How can I avoid expanding pre-existing envs?</summary><br>\n\nAs of `v12.0.0` dotenv-expand no longer expands `process.env`.\n\nIf you need this ability, use [dotenvx](https://dotenvx.com) and ship an encrypted `.env` file with your code, allowing safe expansion at runtime.\n\n</details>\n\n<details><summary>How can I override an existing environment variable?</summary><br>\n\nUse [dotenvx](https://dotenvx.com), as dotenv-expand does not support this.\n\ndotenv-expand is a separate module (without knowledge of the loading of `process.env` and the `.env` file) and so cannot reliably know what to override.\n\n</details>\n\n&nbsp;\n\n## Docs\n\n### Expand\n\n`expand` expands, evaluates, and decrypts values in a dotenv result:\n\n```javascript\nconst dotenvExpand = require('dotenv-expand')\n\nconst result = dotenvExpand.expand({\n  parsed: {\n    BASIC: 'basic',\n    BASIC_EXPAND: '${BASIC}',\n    BASIC_EXPAND_SIMPLE: '$BASIC'\n  }\n})\n\nconsole.log(result.parsed)\n```\n\n#### Options\n\n##### `processEnv`\n\nDefault: `process.env`\n\nSpecify an object to read existing values from and write expanded values to.\n\n##### `parsed`\n\nThe parsed key-value object to expand. This is normally the result of `dotenv.config()`.\n\n&nbsp;\n\n## Contributing\n\nSee [CONTRIBUTING.md](CONTRIBUTING.md).\n\n## CHANGELOG\n\nSee [CHANGELOG.md](CHANGELOG.md).\n\n## Who's using dotenv-expand?\n\n[These npm modules depend on it.](https://www.npmjs.com/browse/depended/dotenv-expand)\n","publish_time":1776462641346,"_cnpm_publish_time":1776462641346,"dist-tags":{"latest":"1000.0.0"}}