{"_id":"dotenv-expand@1000.0.0","bugs":{"url":"https://github.com/dotenvx/dotenv-expand/issues"},"dist":{"shasum":"31d8eda97b3a1a81119e60ee89b08c3e133d777d","tarball":"http://registry-npm.ywwl.com/dotenv-expand/download/dotenv-expand-1000.0.0.tgz","fileCount":8,"integrity":"sha512-3T4TtUjXm5iGKFEirqKjcDJ0EheFJbv9peb5xytC+HNu3l5Ygnu4dYE8yeqkppHMsh1If9C/A//EJu7IPtNu+A==","signatures":[{"sig":"MEUCIQCwvI4d8EubNmyMULm8GH6voHhmdIjXxbysa3uGpiU1zAIgMsc/jEMyNzjJ6W6tMrq4Gvn+C4J6RMxHmUCZjlAr8bI=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQDohc5igfYaGpsY+vi7uSFcsi3j0EhV0n+p3NmrJZ7ZrgIhAJHlaxiRRvwQOXsl4DMqEA1AXH3asvVYFiH44Q1Zz49J"}],"unpackedSize":297631,"size":105675,"noattachment":false,"key":"/dotenv-expand/-/dotenv-expand-1000.0.0.tgz"},"main":"dist/lib/main.js","name":"dotenv-expand","types":"lib/main.d.ts","author":{"name":"motdotla"},"engines":{"node":">=16"},"exports":{".":{"types":"./lib/main.d.ts","default":"./dist/lib/main.js","require":"./dist/lib/main.js"},"./config":"./dist/config.js","./config.js":"./dist/config.js","./package.json":"./package.json"},"funding":"https://dotenvx.com","gitHead":"0d8c9260deaa14bdff175c5da13ac6cc197c4ac2","license":"BSD-3-Clause","scripts":{"lint":"biome lint --diagnostic-level=error lib config.js tests","test":"node tests/main.js","build":"esbuild lib/main.js config.js --bundle --platform=node --format=cjs --target=node16 --outdir=dist --outbase=. --legal-comments=none --minify","prepack":"npm run build","pretest":"npm run lint && npm run dts-check","release":"npm version","dts-check":"tsc --project tests/types/tsconfig.json","prerelease":"npm test","prepublishOnly":"npm pack --dry-run"},"version":"1000.0.0","_npmUser":{"name":"motdotla","email":"mot@mot.la"},"homepage":"https://github.com/dotenvx/dotenv-expand#readme","keywords":["dotenv","expand","variables","interpolation","substitution","env",".env"],"repository":{"url":"git+https://github.com/dotenvx/dotenv-expand.git","type":"git"},"_npmVersion":"11.17.0","description":"Expand environment variables using dotenv","directories":{},"maintainers":[{"name":"motdotla","email":"mot@mot.la"}],"_nodeVersion":"26.5.0","_hasShrinkwrap":false,"devDependencies":{"dotenv":"^17.4.2","esbuild":"^0.28.1","typescript":"^4.5.4","@types/node":"^18.11.3","@biomejs/biome":"^2.5.6","@dotenvx/primitives":"2.1.1"},"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/dotenv-expand_1000.0.0_1785350128597_0.9913070959280041"},"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":1785350128694,"_cnpm_publish_time":1785350128694,"dist-tags":{"latest":"1000.0.0"}}