{"_id":"@weirdorg/dotenv","_rev":"5-2cdf1b29353a26d6f7f5d7d2aecdd627","name":"@weirdorg/dotenv","dist-tags":{"latest":"1.0.4"},"versions":{"1.0.0":{"name":"@weirdorg/dotenv","version":"1.0.0","keywords":["dotenv","env",".env","environment","variables","config","settings"],"license":"BSD-2-Clause","_id":"@weirdorg/dotenv@1.0.0","maintainers":[{"name":"chen1567851","email":"chen.wei970116@gmail.com"}],"homepage":"https://github.com/weirdorg/dotenv#readme","bugs":{"url":"https://github.com/weirdorg/dotenv/issues"},"dist":{"shasum":"dd85e6c0ce391d7973a0b465b70e38a32f5c591e","tarball":"https://registry.npmjs.org/@weirdorg/dotenv/-/dotenv-1.0.0.tgz","fileCount":9,"integrity":"sha512-Vf94+kt2vIJdWy2o10eh9tH5tF1JVhlM6hSFxd2K5SwLSvH/b6JBOqLFaojXHS5pGjMLxNJu0CpoitgOB2xHHw==","signatures":[{"sig":"MEQCIGI0M8oFmsuYmMqaS8hLxf+qEYwew2Zwq+YCLZ0shSevAiBvCUglRmAYo3bx8SYaiwyA5lGwKGXEpKvR6K/jCJmoTQ==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":44744},"main":"lib/main.js","types":"lib/main.d.ts","browser":{"fs":false},"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","./lib/cli-options":"./lib/cli-options.js","./lib/env-options":"./lib/env-options.js","./lib/cli-options.js":"./lib/cli-options.js","./lib/env-options.js":"./lib/env-options.js"},"funding":"https://dotenvx.com","gitHead":"25f120b7f159600cfbe81cfc87103c49e55220fe","scripts":{"lint":"standard","test":"tap run tests/**/*.js --allow-empty-coverage --disable-coverage --timeout=60000","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 run tests/**/*.js --show-full-coverage --timeout=60000 --coverage-report=text --coverage-report=lcov"},"_npmUser":{"name":"chen1567851","email":"chen.wei970116@gmail.com"},"repository":{"url":"git://github.com/weirdorg/dotenv.git","type":"git"},"_npmVersion":"11.6.2","description":"Loads environment variables from .env file","directories":{},"_nodeVersion":"24.11.1","dependencies":{"tap":"^19.2.0","sinon":"^14.0.1","standard":"^17.0.0","standard-version":"^9.5.0","@uallianceorg/config":"^1.0.0"},"_hasShrinkwrap":false,"devDependencies":{"decache":"^4.6.2","typescript":"^4.8.4","@types/node":"^18.11.3"},"_npmOperationalInternal":{"tmp":"tmp/dotenv_1.0.0_1776783527827_0.1349029532870254","host":"s3://npm-registry-packages-npm-production"}},"1.0.1":{"name":"@weirdorg/dotenv","version":"1.0.1","keywords":["dotenv","env",".env","environment","variables","config","settings"],"license":"BSD-2-Clause","_id":"@weirdorg/dotenv@1.0.1","maintainers":[{"name":"chen1567851","email":"chen.wei970116@gmail.com"}],"homepage":"https://github.com/weirdorg/dotenv#readme","bugs":{"url":"https://github.com/weirdorg/dotenv/issues"},"dist":{"shasum":"3adf41de9ae7b6b883961ffd65bd87046c398c68","tarball":"https://registry.npmjs.org/@weirdorg/dotenv/-/dotenv-1.0.1.tgz","fileCount":9,"integrity":"sha512-IFeaa8Rdp+FwwDeGtFJLzm3KNtdWowmUgSfjTNPtgXGfbMjt+oMjlkMy/coK/TivyYB54xpmZIDmVPm3cnSM6w==","signatures":[{"sig":"MEUCIQDx069OjHdK4wlIE4uiH6mFhG4zaK2knOxTwj02j8IaCQIgRvkH5xInwllCv252MC6qcFxgE/Wrsb2NXyCmV3C4a/Q=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":44740},"main":"lib/main.js","types":"lib/main.d.ts","browser":{"fs":false},"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","./lib/cli-options":"./lib/cli-options.js","./lib/env-options":"./lib/env-options.js","./lib/cli-options.js":"./lib/cli-options.js","./lib/env-options.js":"./lib/env-options.js"},"funding":"https://dotenvx.com","gitHead":"25f120b7f159600cfbe81cfc87103c49e55220fe","scripts":{"lint":"standard","test":"tap run tests/**/*.js --allow-empty-coverage --disable-coverage --timeout=60000","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 run tests/**/*.js --show-full-coverage --timeout=60000 --coverage-report=text --coverage-report=lcov"},"_npmUser":{"name":"chen1567851","email":"chen.wei970116@gmail.com"},"repository":{"url":"git://github.com/weirdorg/dotenv.git","type":"git"},"_npmVersion":"11.6.2","description":"Loads environment variables from .env file","directories":{},"_nodeVersion":"24.11.1","dependencies":{"tap":"^19.2.0","sinon":"^14.0.1","standard":"^17.0.0","@weirdorg/config":"^1.0.0","standard-version":"^9.5.0"},"_hasShrinkwrap":false,"devDependencies":{"decache":"^4.6.2","typescript":"^4.8.4","@types/node":"^18.11.3"},"_npmOperationalInternal":{"tmp":"tmp/dotenv_1.0.1_1776784211059_0.20396244201747682","host":"s3://npm-registry-packages-npm-production"}},"1.0.2":{"name":"@weirdorg/dotenv","version":"1.0.2","keywords":["dotenv","env",".env","environment","variables","config","settings"],"license":"BSD-2-Clause","_id":"@weirdorg/dotenv@1.0.2","maintainers":[{"name":"chen1567851","email":"chen.wei970116@gmail.com"}],"homepage":"https://github.com/weirdorg/dotenv#readme","bugs":{"url":"https://github.com/weirdorg/dotenv/issues"},"dist":{"shasum":"444648f6af0708191f7eb54140d290e730aa749c","tarball":"https://registry.npmjs.org/@weirdorg/dotenv/-/dotenv-1.0.2.tgz","fileCount":9,"integrity":"sha512-2GtAn43Vw8IJ5nvK2AQyFZJ10Zw2BErt4ir7xpg9SmwvhkrEU7qpDfHvCY+PMqFFcFHA7LKmPXJN42RNo3ltTQ==","signatures":[{"sig":"MEUCIQDCHoP13O1iD4xJ++Oc16G6gzMNCaXgzDZMG+qZDgtahQIgWH8Pl3YgIMjybXp8bql5D3swVsdcjfCsCMLESeukl8o=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":44740},"main":"lib/main.js","types":"lib/main.d.ts","browser":{"fs":false},"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","./lib/cli-options":"./lib/cli-options.js","./lib/env-options":"./lib/env-options.js","./lib/cli-options.js":"./lib/cli-options.js","./lib/env-options.js":"./lib/env-options.js"},"funding":"https://dotenvx.com","gitHead":"e4c980bbee07fb0824f1b4d8a20e1b979c2a5de7","scripts":{"lint":"standard","test":"tap run tests/**/*.js --allow-empty-coverage --disable-coverage --timeout=60000","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 run tests/**/*.js --show-full-coverage --timeout=60000 --coverage-report=text --coverage-report=lcov"},"_npmUser":{"name":"chen1567851","email":"chen.wei970116@gmail.com"},"repository":{"url":"git://github.com/weirdorg/dotenv.git","type":"git"},"_npmVersion":"11.6.2","description":"Loads environment variables from .env file","directories":{},"_nodeVersion":"24.11.1","dependencies":{"tap":"^19.2.0","sinon":"^14.0.1","standard":"^17.0.0","@weirdorg/config":"^1.0.1","standard-version":"^9.5.0"},"_hasShrinkwrap":false,"devDependencies":{"decache":"^4.6.2","typescript":"^4.8.4","@types/node":"^18.11.3"},"_npmOperationalInternal":{"tmp":"tmp/dotenv_1.0.2_1777306399909_0.4095247791972483","host":"s3://npm-registry-packages-npm-production"}},"1.0.3":{"name":"@weirdorg/dotenv","version":"1.0.3","keywords":["dotenv","env",".env","environment","variables","config","settings"],"license":"BSD-2-Clause","_id":"@weirdorg/dotenv@1.0.3","maintainers":[{"name":"chen1567851","email":"chen.wei970116@gmail.com"}],"homepage":"https://github.com/weirdorg/dotenv#readme","bugs":{"url":"https://github.com/weirdorg/dotenv/issues"},"dist":{"shasum":"0022889b4b6fc81ff0c4531ee4cd1dd191dcacbe","tarball":"https://registry.npmjs.org/@weirdorg/dotenv/-/dotenv-1.0.3.tgz","fileCount":9,"integrity":"sha512-p773QeGqRpIcxmY+YMTqBb6zIvSPhmEHPThMbrtEiKGkmVijvg0NxhMrchY7KFCUZHBZLsFz1k9bDzdPUTAdXg==","signatures":[{"sig":"MEUCIE1OYRaOtgNJ0eCXHUmBQp2BxwGH+W1L0kTC9vgv7+xfAiEAvgzpDfBCwuHjb2IRC8W8XKxT/LCRIe8ynl5TUOOpkRY=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":44740},"main":"lib/main.js","types":"lib/main.d.ts","browser":{"fs":false},"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","./lib/cli-options":"./lib/cli-options.js","./lib/env-options":"./lib/env-options.js","./lib/cli-options.js":"./lib/cli-options.js","./lib/env-options.js":"./lib/env-options.js"},"funding":"https://dotenvx.com","gitHead":"0525f6d1b7c536bccc2b637d64abc02b5b29bcd6","scripts":{"lint":"standard","test":"tap run tests/**/*.js --allow-empty-coverage --disable-coverage --timeout=60000","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 run tests/**/*.js --show-full-coverage --timeout=60000 --coverage-report=text --coverage-report=lcov"},"_npmUser":{"name":"chen1567851","email":"chen.wei970116@gmail.com"},"repository":{"url":"git://github.com/weirdorg/dotenv.git","type":"git"},"_npmVersion":"11.6.2","description":"Loads environment variables from .env file","directories":{},"_nodeVersion":"24.11.1","dependencies":{"tap":"^19.2.0","sinon":"^14.0.1","standard":"^17.0.0","@weirdorg/config":"^1.0.2","standard-version":"^9.5.0"},"_hasShrinkwrap":false,"devDependencies":{"decache":"^4.6.2","typescript":"^4.8.4","@types/node":"^18.11.3"},"_npmOperationalInternal":{"tmp":"tmp/dotenv_1.0.3_1777761715123_0.2091987749409765","host":"s3://npm-registry-packages-npm-production"}},"1.0.4":{"name":"@weirdorg/dotenv","version":"1.0.4","description":"Loads environment variables from .env file","main":"lib/main.js","types":"lib/main.d.ts","exports":{".":{"types":"./lib/main.d.ts","require":"./lib/main.js","default":"./lib/main.js"},"./config":"./config.js","./config.js":"./config.js","./lib/env-options":"./lib/env-options.js","./lib/env-options.js":"./lib/env-options.js","./lib/cli-options":"./lib/cli-options.js","./lib/cli-options.js":"./lib/cli-options.js","./package.json":"./package.json"},"scripts":{"dts-check":"tsc --project tests/types/tsconfig.json","lint":"standard","pretest":"npm run lint && npm run dts-check","test":"tap run tests/**/*.js --allow-empty-coverage --disable-coverage --timeout=60000","test:coverage":"tap run tests/**/*.js --show-full-coverage --timeout=60000 --coverage-report=text --coverage-report=lcov","prerelease":"npm test","release":"standard-version"},"repository":{"type":"git","url":"git://github.com/weirdorg/dotenv.git"},"homepage":"https://github.com/weirdorg/dotenv#readme","funding":"https://dotenvx.com","keywords":["dotenv","env",".env","environment","variables","config","settings"],"license":"BSD-2-Clause","dependencies":{"@weirdorg/config":"^1.0.3","sinon":"^14.0.1","standard":"^17.0.0","standard-version":"^9.5.0","tap":"^19.2.0"},"devDependencies":{"@types/node":"^18.11.3","decache":"^4.6.2","typescript":"^4.8.4"},"engines":{"node":">=12"},"browser":{"fs":false},"gitHead":"e6afb7a27ccdb9d4b5ae858027949d2eaef2213d","_id":"@weirdorg/dotenv@1.0.4","bugs":{"url":"https://github.com/weirdorg/dotenv/issues"},"_nodeVersion":"24.11.1","_npmVersion":"11.6.2","dist":{"integrity":"sha512-6174oyD0eFW6+KgYw6dXsrR3APclH9yZSSSAYplp8CCZbuHJcdF5q6NPhmiLEagOIORZnlVrvek+qVwbZp/dXQ==","shasum":"8691312244a0100f99265d8ba5f681cec5621703","tarball":"https://registry.npmjs.org/@weirdorg/dotenv/-/dotenv-1.0.4.tgz","fileCount":9,"unpackedSize":44740,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCICx8jnMFbhxVfw1Q0zjv3rcEecZ2dO9+DqeoRJMZ9IHbAiBZQu604LeNaQf6DEUwXqRvOnJPR4qiAk3DqdIubrAAYg=="}]},"_npmUser":{"name":"chen1567851","email":"chen.wei970116@gmail.com"},"directories":{},"maintainers":[{"name":"chen1567851","email":"chen.wei970116@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/dotenv_1.0.4_1779129069200_0.7395686607581002"},"_hasShrinkwrap":false}},"time":{"created":"2026-04-21T14:58:47.737Z","modified":"2026-05-18T18:31:09.553Z","1.0.0":"2026-04-21T14:58:47.969Z","1.0.1":"2026-04-21T15:10:11.199Z","1.0.2":"2026-04-27T16:13:20.138Z","1.0.3":"2026-05-02T22:41:55.284Z","1.0.4":"2026-05-18T18:31:09.389Z"},"bugs":{"url":"https://github.com/weirdorg/dotenv/issues"},"license":"BSD-2-Clause","homepage":"https://github.com/weirdorg/dotenv#readme","keywords":["dotenv","env",".env","environment","variables","config","settings"],"repository":{"type":"git","url":"git://github.com/weirdorg/dotenv.git"},"description":"Loads environment variables from .env file","maintainers":[{"name":"chen1567851","email":"chen.wei970116@gmail.com"}],"readme":"# dotenv [![NPM version](https://img.shields.io/npm/v/dotenv.svg?style=flat-square)](https://www.npmjs.com/package/dotenv)\r\n\r\nDotenv is a zero-dependency module that loads environment variables from a `.env` file into [`process.env`](https://nodejs.org/docs/latest/api/process.html#process_process_env). Storing configuration in the environment separate from code is based on [The Twelve-Factor App](https://12factor.net/config) methodology.\r\n\r\n[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square)](https://github.com/feross/standard)\r\n[![LICENSE](https://img.shields.io/github/license/motdotla/dotenv.svg)](LICENSE)\r\n[![codecov](https://codecov.io/gh/motdotla/dotenv-expand/graph/badge.svg?token=pawWEyaMfg)](https://codecov.io/gh/motdotla/dotenv-expand)\r\n\r\n* [🌱 Install](#-install)\r\n* [🏗️ Usage (.env)](#%EF%B8%8F-usage)\r\n* [🌴 Multiple Environments 🆕](#-manage-multiple-environments)\r\n* [🚀 Deploying (encryption) 🆕](#-deploying)\r\n* [📚 Examples](#-examples)\r\n* [📖 Docs](#-documentation)\r\n* [❓ FAQ](#-faq)\r\n* [⏱️ Changelog](./CHANGELOG.md)\r\n\r\n## 🌱 Install\r\n\r\n```bash\r\nnpm install dotenv --save\r\n```\r\n\r\nYou can also use an npm-compatible package manager like yarn, bun or pnpm:\r\n\r\n```bash\r\nyarn add dotenv\r\n```\r\n```bash\r\nbun add dotenv\r\n```\r\n```bash\r\npnpm add dotenv\r\n```\r\n\r\nCreate a `.env` file in the root of your project (if using a monorepo structure like `apps/backend/app.js`, put it in the root of the folder where your `app.js` process runs):\r\n\r\n```dosini\r\nS3_BUCKET=\"YOURS3BUCKET\"\r\nSECRET_KEY=\"YOURSECRETKEYGOESHERE\"\r\n```\r\n\r\nAs early as possible in your application, import and configure dotenv:\r\n\r\n```javascript\r\nrequire('dotenv').config()\r\nconsole.log(process.env) // remove this after you've confirmed it is working\r\n```\r\n\r\n.. [or using ES6?](#how-do-i-use-dotenv-with-import)\r\n\r\n```javascript\r\nimport 'dotenv/config'\r\n```\r\n\r\nES6 import if you need to set config options:\r\n\r\n```javascript\r\nimport dotenv from 'dotenv'\r\n\r\ndotenv.config({ path: '/custom/path/to/.env' })\r\n```\r\n\r\nThat's it. `process.env` now has the keys and values you defined in your `.env` file:\r\n\r\n```javascript\r\nrequire('dotenv').config()\r\n// or import 'dotenv/config' if you're using ES6\r\n\r\n...\r\n\r\ns3.getBucketCors({Bucket: process.env.S3_BUCKET}, function(err, data) {})\r\n```\r\n\r\n### Multiline values\r\n\r\nIf you need multiline variables, for example private keys, those are now supported (`>= v15.0.0`) with line breaks:\r\n\r\n```dosini\r\nPRIVATE_KEY=\"-----BEGIN RSA PRIVATE KEY-----\r\n...\r\nKh9NV...\r\n...\r\n-----END RSA PRIVATE KEY-----\"\r\n```\r\n\r\nAlternatively, you can double quote strings and use the `\\n` character:\r\n\r\n```dosini\r\nPRIVATE_KEY=\"-----BEGIN RSA PRIVATE KEY-----\\nKh9NV...\\n-----END RSA PRIVATE KEY-----\\n\"\r\n```\r\n\r\n### Comments\r\n\r\nComments may be added to your file on their own line or inline:\r\n\r\n```dosini\r\n# This is a comment\r\nSECRET_KEY=YOURSECRETKEYGOESHERE # comment\r\nSECRET_HASH=\"something-with-a-#-hash\"\r\n```\r\n\r\nComments begin where a `#` exists, so if your value contains a `#` please wrap it in quotes. This is a breaking change from `>= v15.0.0` and on.\r\n\r\n### Parsing\r\n\r\nThe engine which parses the contents of your file containing environment variables is available to use. It accepts a String or Buffer and will return an Object with the parsed keys and values.\r\n\r\n```javascript\r\nconst dotenv = require('dotenv')\r\nconst buf = Buffer.from('BASIC=basic')\r\nconst config = dotenv.parse(buf) // will return an object\r\nconsole.log(typeof config, config) // object { BASIC : 'basic' }\r\n```\r\n\r\n### Preload\r\n\r\n> Note: Consider using [`dotenvx`](https://github.com/dotenvx/dotenvx) instead of preloading. I am now doing (and recommending) so.\r\n>\r\n> It serves the same purpose (you do not need to require and load dotenv), adds better debugging, and works with ANY language, framework, or platform. – [motdotla](https://github.com/motdotla)\r\n\r\nYou can use the `--require` (`-r`) [command line option](https://nodejs.org/api/cli.html#-r---require-module) to preload dotenv. By doing this, you do not need to require and load dotenv in your application code.\r\n\r\n```bash\r\n$ node -r dotenv/config your_script.js\r\n```\r\n\r\nThe configuration options below are supported as command line arguments in the format `dotenv_config_<option>=value`\r\n\r\n```bash\r\n$ node -r dotenv/config your_script.js dotenv_config_path=/custom/path/to/.env dotenv_config_debug=true\r\n```\r\n\r\nAdditionally, you can use environment variables to set configuration options. Command line arguments will precede these.\r\n\r\n```bash\r\n$ DOTENV_CONFIG_<OPTION>=value node -r dotenv/config your_script.js\r\n```\r\n\r\n```bash\r\n$ DOTENV_CONFIG_ENCODING=latin1 DOTENV_CONFIG_DEBUG=true node -r dotenv/config your_script.js dotenv_config_path=/custom/path/to/.env\r\n```\r\n\r\n### Variable Expansion\r\n\r\nUse [dotenvx](https://github.com/dotenvx/dotenvx) to use variable expansion.\r\n\r\nReference and expand variables already on your machine for use in your .env file.\r\n\r\n```ini\r\n# .env\r\nUSERNAME=\"username\"\r\nDATABASE_URL=\"postgres://${USERNAME}@localhost/my_database\"\r\n```\r\n```js\r\n// index.js\r\nconsole.log('DATABASE_URL', process.env.DATABASE_URL)\r\n```\r\n```sh\r\n$ dotenvx run --debug -- node index.js\r\n[dotenvx@0.14.1] injecting env (2) from .env\r\nDATABASE_URL postgres://username@localhost/my_database\r\n```\r\n\r\n### Command Substitution\r\n\r\nUse [dotenvx](https://github.com/dotenvx/dotenvx) to use command substitution.\r\n\r\nAdd the output of a command to one of your variables in your .env file.\r\n\r\n```ini\r\n# .env\r\nDATABASE_URL=\"postgres://$(whoami)@localhost/my_database\"\r\n```\r\n```js\r\n// index.js\r\nconsole.log('DATABASE_URL', process.env.DATABASE_URL)\r\n```\r\n```sh\r\n$ dotenvx run --debug -- node index.js\r\n[dotenvx@0.14.1] injecting env (1) from .env\r\nDATABASE_URL postgres://yourusername@localhost/my_database\r\n```\r\n\r\n### Syncing\r\n\r\nYou need to keep `.env` files in sync between machines, environments, or team members? Use [dotenvx](https://github.com/dotenvx/dotenvx) to encrypt your `.env` files and safely include them in source control. This still subscribes to the twelve-factor app rules by generating a decryption key separate from code.\r\n\r\n### Multiple Environments\r\n\r\nUse [dotenvx](https://github.com/dotenvx/dotenvx) to generate `.env.ci`, `.env.production` files, and more.\r\n\r\n### Deploying\r\n\r\nYou need to deploy your secrets in a cloud-agnostic manner? Use [dotenvx](https://github.com/dotenvx/dotenvx) to generate a private decryption key that is set on your production server.\r\n\r\n## 🌴 Manage Multiple Environments\r\n\r\nUse [dotenvx](https://github.com/dotenvx/dotenvx)\r\n\r\nRun any environment locally. Create a `.env.ENVIRONMENT` file and use `--env-file` to load it. It's straightforward, yet flexible.\r\n\r\n```bash\r\n$ echo \"HELLO=production\" > .env.production\r\n$ echo \"console.log('Hello ' + process.env.HELLO)\" > index.js\r\n\r\n$ dotenvx run --env-file=.env.production -- node index.js\r\nHello production\r\n> ^^\r\n```\r\n\r\nor with multiple .env files\r\n\r\n```bash\r\n$ echo \"HELLO=local\" > .env.local\r\n$ echo \"HELLO=World\" > .env\r\n$ echo \"console.log('Hello ' + process.env.HELLO)\" > index.js\r\n\r\n$ dotenvx run --env-file=.env.local --env-file=.env -- node index.js\r\nHello local\r\n```\r\n\r\n[more environment examples](https://dotenvx.com/docs/quickstart/environments)\r\n\r\n## 🚀 Deploying\r\n\r\nUse [dotenvx](https://github.com/dotenvx/dotenvx).\r\n\r\nAdd encryption to your `.env` files with a single command. Pass the `--encrypt` flag.\r\n\r\n```\r\n$ dotenvx set HELLO Production --encrypt -f .env.production\r\n$ echo \"console.log('Hello ' + process.env.HELLO)\" > index.js\r\n\r\n$ DOTENV_PRIVATE_KEY_PRODUCTION=\"<.env.production private key>\" dotenvx run -- node index.js\r\n[dotenvx] injecting env (2) from .env.production\r\nHello Production\r\n```\r\n\r\n[learn more](https://github.com/dotenvx/dotenvx?tab=readme-ov-file#encryption)\r\n\r\n## 📚 Examples\r\n\r\nSee [examples](https://github.com/dotenv-org/examples) of using dotenv with various frameworks, languages, and configurations.\r\n\r\n* [nodejs](https://github.com/dotenv-org/examples/tree/master/usage/dotenv-nodejs)\r\n* [nodejs (debug on)](https://github.com/dotenv-org/examples/tree/master/usage/dotenv-nodejs-debug)\r\n* [nodejs (override on)](https://github.com/dotenv-org/examples/tree/master/usage/dotenv-nodejs-override)\r\n* [nodejs (processEnv override)](https://github.com/dotenv-org/examples/tree/master/usage/dotenv-custom-target)\r\n* [esm](https://github.com/dotenv-org/examples/tree/master/usage/dotenv-esm)\r\n* [esm (preload)](https://github.com/dotenv-org/examples/tree/master/usage/dotenv-esm-preload)\r\n* [typescript](https://github.com/dotenv-org/examples/tree/master/usage/dotenv-typescript)\r\n* [typescript parse](https://github.com/dotenv-org/examples/tree/master/usage/dotenv-typescript-parse)\r\n* [typescript config](https://github.com/dotenv-org/examples/tree/master/usage/dotenv-typescript-config)\r\n* [webpack](https://github.com/dotenv-org/examples/tree/master/usage/dotenv-webpack)\r\n* [webpack (plugin)](https://github.com/dotenv-org/examples/tree/master/usage/dotenv-webpack2)\r\n* [react](https://github.com/dotenv-org/examples/tree/master/usage/dotenv-react)\r\n* [react (typescript)](https://github.com/dotenv-org/examples/tree/master/usage/dotenv-react-typescript)\r\n* [express](https://github.com/dotenv-org/examples/tree/master/usage/dotenv-express)\r\n* [nestjs](https://github.com/dotenv-org/examples/tree/master/usage/dotenv-nestjs)\r\n* [fastify](https://github.com/dotenv-org/examples/tree/master/usage/dotenv-fastify)\r\n\r\n## 📖 Documentation\r\n\r\nDotenv exposes four functions:\r\n\r\n* `config`\r\n* `parse`\r\n* `populate`\r\n\r\n### Config\r\n\r\n`config` will read your `.env` file, parse the contents, assign it to\r\n[`process.env`](https://nodejs.org/docs/latest/api/process.html#process_process_env),\r\nand return an Object with a `parsed` key containing the loaded content or an `error` key if it failed.\r\n\r\n```js\r\nconst result = dotenv.config()\r\n\r\nif (result.error) {\r\n  throw result.error\r\n}\r\n\r\nconsole.log(result.parsed)\r\n```\r\n\r\nYou can additionally, pass options to `config`.\r\n\r\n#### Options\r\n\r\n##### path\r\n\r\nDefault: `path.resolve(process.cwd(), '.env')`\r\n\r\nSpecify a custom path if your file containing environment variables is located elsewhere.\r\n\r\n```js\r\nrequire('dotenv').config({ path: '/custom/path/to/.env' })\r\n```\r\n\r\nBy default, `config` will look for a file called .env in the current working directory.\r\n\r\nPass in multiple files as an array, and they will be parsed in order and combined with `process.env` (or `option.processEnv`, if set). The first value set for a variable will win, unless the `options.override` flag is set, in which case the last value set will win.  If a value already exists in `process.env` and the `options.override` flag is NOT set, no changes will be made to that value. \r\n\r\n```js  \r\nrequire('dotenv').config({ path: ['.env.local', '.env'] })\r\n```\r\n\r\n##### quiet\r\n\r\nDefault: `false`\r\n\r\nSuppress runtime logging message.\r\n\r\n```js\r\n// index.js\r\nrequire('dotenv').config({ quiet: false }) // change to true to suppress\r\nconsole.log(`Hello ${process.env.HELLO}`)\r\n```\r\n\r\n```ini\r\n# .env\r\n.env\r\n```\r\n\r\n```sh\r\n$ node index.js\r\n[dotenv@17.0.0] injecting env (1) from .env\r\nHello World\r\n```\r\n\r\n##### encoding\r\n\r\nDefault: `utf8`\r\n\r\nSpecify the encoding of your file containing environment variables.\r\n\r\n```js\r\nrequire('dotenv').config({ encoding: 'latin1' })\r\n```\r\n\r\n##### debug\r\n\r\nDefault: `false`\r\n\r\nTurn on logging to help debug why certain keys or values are not being set as you expect.\r\n\r\n```js\r\nrequire('dotenv').config({ debug: process.env.DEBUG })\r\n```\r\n\r\n##### override\r\n\r\nDefault: `false`\r\n\r\nOverride any environment variables that have already been set on your machine with values from your .env file(s). If multiple files have been provided in `option.path` the override will also be used as each file is combined with the next. Without `override` being set, the first value wins. With `override` set the last value wins. \r\n\r\n```js\r\nrequire('dotenv').config({ override: true })\r\n```\r\n\r\n##### processEnv\r\n\r\nDefault: `process.env`\r\n\r\nSpecify an object to write your environment variables to. Defaults to `process.env` environment variables.\r\n\r\n```js\r\nconst myObject = {}\r\nrequire('dotenv').config({ processEnv: myObject })\r\n\r\nconsole.log(myObject) // values from .env\r\nconsole.log(process.env) // this was not changed or written to\r\n```\r\n\r\n### Parse\r\n\r\nThe engine which parses the contents of your file containing environment\r\nvariables is available to use. It accepts a String or Buffer and will return\r\nan Object with the parsed keys and values.\r\n\r\n```js\r\nconst dotenv = require('dotenv')\r\nconst buf = Buffer.from('BASIC=basic')\r\nconst config = dotenv.parse(buf) // will return an object\r\nconsole.log(typeof config, config) // object { BASIC : 'basic' }\r\n```\r\n\r\n#### Options\r\n\r\n##### debug\r\n\r\nDefault: `false`\r\n\r\nTurn on logging to help debug why certain keys or values are not being set as you expect.\r\n\r\n```js\r\nconst dotenv = require('dotenv')\r\nconst buf = Buffer.from('hello world')\r\nconst opt = { debug: true }\r\nconst config = dotenv.parse(buf, opt)\r\n// expect a debug message because the buffer is not in KEY=VAL form\r\n```\r\n\r\n### Populate\r\n\r\nThe engine which populates the contents of your .env file to `process.env` is available for use. It accepts a target, a source, and options. This is useful for power users who want to supply their own objects.\r\n\r\nFor example, customizing the source:\r\n\r\n```js\r\nconst dotenv = require('dotenv')\r\nconst parsed = { HELLO: 'world' }\r\n\r\ndotenv.populate(process.env, parsed)\r\n\r\nconsole.log(process.env.HELLO) // world\r\n```\r\n\r\nFor example, customizing the source AND target:\r\n\r\n```js\r\nconst dotenv = require('dotenv')\r\nconst parsed = { HELLO: 'universe' }\r\nconst target = { HELLO: 'world' } // empty object\r\n\r\ndotenv.populate(target, parsed, { override: true, debug: true })\r\n\r\nconsole.log(target) // { HELLO: 'universe' }\r\n```\r\n\r\n#### options\r\n\r\n##### Debug\r\n\r\nDefault: `false`\r\n\r\nTurn on logging to help debug why certain keys or values are not being populated as you expect.\r\n\r\n##### override\r\n\r\nDefault: `false`\r\n\r\nOverride any environment variables that have already been set.\r\n\r\n## ❓ FAQ\r\n\r\n### Why is the `.env` file not loading my environment variables successfully?\r\n\r\nMost likely your `.env` file is not in the correct place. [See this stack overflow](https://stackoverflow.com/questions/42335016/dotenv-file-is-not-loading-environment-variables).\r\n\r\nTurn on debug mode and try again..\r\n\r\n```js\r\nrequire('dotenv').config({ debug: true })\r\n```\r\n\r\nYou will receive a helpful error outputted to your console.\r\n\r\n### Should I commit my `.env` file?\r\n\r\nNo. We **strongly** recommend against committing your `.env` file to version\r\ncontrol. It should only include environment-specific values such as database\r\npasswords or API keys. Your production database should have a different\r\npassword than your development database.\r\n\r\n### Should I have multiple `.env` files?\r\n\r\nWe recommend creating one `.env` file per environment. Use `.env` for local/development, `.env.production` for production and so on. This still follows the twelve factor principles as each is attributed individually to its own environment. Avoid custom set ups that work in inheritance somehow (`.env.production` inherits values form `.env` for example). It is better to duplicate values if necessary across each `.env.environment` file.\r\n\r\n> In a twelve-factor app, env vars are granular controls, each fully orthogonal to other env vars. They are never grouped together as “environments”, but instead are independently managed for each deploy. This is a model that scales up smoothly as the app naturally expands into more deploys over its lifetime.\r\n>\r\n> – [The Twelve-Factor App](http://12factor.net/config)\r\n\r\n### What rules does the parsing engine follow?\r\n\r\nThe parsing engine currently supports the following rules:\r\n\r\n- `BASIC=basic` becomes `{BASIC: 'basic'}`\r\n- empty lines are skipped\r\n- lines beginning with `#` are treated as comments\r\n- `#` marks the beginning of a comment (unless when the value is wrapped in quotes)\r\n- empty values become empty strings (`EMPTY=` becomes `{EMPTY: ''}`)\r\n- inner quotes are maintained (think JSON) (`JSON={\"foo\": \"bar\"}` becomes `{JSON:\"{\\\"foo\\\": \\\"bar\\\"}\"`)\r\n- whitespace is removed from both ends of unquoted values (see more on [`trim`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/Trim)) (`FOO=  some value  ` becomes `{FOO: 'some value'}`)\r\n- single and double quoted values are escaped (`SINGLE_QUOTE='quoted'` becomes `{SINGLE_QUOTE: \"quoted\"}`)\r\n- single and double quoted values maintain whitespace from both ends (`FOO=\"  some value  \"` becomes `{FOO: '  some value  '}`)\r\n- double quoted values expand new lines (`MULTILINE=\"new\\nline\"` becomes\r\n\r\n```\r\n{MULTILINE: 'new\r\nline'}\r\n```\r\n\r\n- backticks are supported (`` BACKTICK_KEY=`This has 'single' and \"double\" quotes inside of it.` ``)\r\n\r\n### What happens to environment variables that were already set?\r\n\r\nBy default, we will never modify any environment variables that have already been set. In particular, if there is a variable in your `.env` file which collides with one that already exists in your environment, then that variable will be skipped.\r\n\r\nIf instead, you want to override `process.env` use the `override` option.\r\n\r\n```javascript\r\nrequire('dotenv').config({ override: true })\r\n```\r\n\r\n### How come my environment variables are not showing up for React?\r\n\r\nYour React code is run in Webpack, where the `fs` module or even the `process` global itself are not accessible out-of-the-box. `process.env` can only be injected through Webpack configuration.\r\n\r\nIf you are using [`react-scripts`](https://www.npmjs.com/package/react-scripts), which is distributed through [`create-react-app`](https://create-react-app.dev/), it has dotenv built in but with a quirk. Preface your environment variables with `REACT_APP_`. See [this stack overflow](https://stackoverflow.com/questions/42182577/is-it-possible-to-use-dotenv-in-a-react-project) for more details.\r\n\r\nIf you are using other frameworks (e.g. Next.js, Gatsby...), you need to consult their documentation for how to inject environment variables into the client.\r\n\r\n### Can I customize/write plugins for dotenv?\r\n\r\nYes! `dotenv.config()` returns an object representing the parsed `.env` file. This gives you everything you need to continue setting values on `process.env`. For example:\r\n\r\n```js\r\nconst dotenv = require('dotenv')\r\nconst variableExpansion = require('dotenv-expand')\r\nconst myEnv = dotenv.config()\r\nvariableExpansion(myEnv)\r\n```\r\n\r\n### How do I use dotenv with `import`?\r\n\r\nSimply..\r\n\r\n```javascript\r\n// index.mjs (ESM)\r\nimport 'dotenv/config' // see https://github.com/motdotla/dotenv#how-do-i-use-dotenv-with-import\r\nimport express from 'express'\r\n```\r\n\r\nA little background..\r\n\r\n> When you run a module containing an `import` declaration, the modules it imports are loaded first, then each module body is executed in a depth-first traversal of the dependency graph, avoiding cycles by skipping anything already executed.\r\n>\r\n> – [ES6 In Depth: Modules](https://hacks.mozilla.org/2015/08/es6-in-depth-modules/)\r\n\r\nWhat does this mean in plain language? It means you would think the following would work but it won't.\r\n\r\n`errorReporter.mjs`:\r\n```js\r\nclass Client {\r\n  constructor (apiKey) {\r\n    console.log('apiKey', apiKey)\r\n\r\n    this.apiKey = apiKey\r\n  }\r\n}\r\n\r\nexport default new Client(process.env.API_KEY)\r\n```\r\n`index.mjs`:\r\n```js\r\n// Note: this is INCORRECT and will not work\r\nimport * as dotenv from 'dotenv'\r\ndotenv.config()\r\n\r\nimport errorReporter from './errorReporter.mjs' // process.env.API_KEY will be blank!\r\n```\r\n\r\n`process.env.API_KEY` will be blank.\r\n\r\nInstead, `index.mjs` should be written as..\r\n\r\n```js\r\nimport 'dotenv/config'\r\n\r\nimport errorReporter from './errorReporter.mjs'\r\n```\r\n\r\nDoes that make sense? It's a bit unintuitive, but it is how importing of ES6 modules work. Here is a [working example of this pitfall](https://github.com/dotenv-org/examples/tree/master/usage/dotenv-es6-import-pitfall).\r\n\r\nThere are two alternatives to this approach:\r\n\r\n1. Preload with dotenvx: `dotenvx run -- node index.js` (_Note: you do not need to `import` dotenv with this approach_)\r\n2. Create a separate file that will execute `config` first as outlined in [this comment on #133](https://github.com/motdotla/dotenv/issues/133#issuecomment-255298822)\r\n\r\n### Why am I getting the error `Module not found: Error: Can't resolve 'crypto|os|path'`?\r\n\r\nYou are using dotenv on the front-end and have not included a polyfill. Webpack < 5 used to include these for you. Do the following:\r\n\r\n```bash\r\nnpm install node-polyfill-webpack-plugin\r\n```\r\n\r\nConfigure your `webpack.config.js` to something like the following.\r\n\r\n```js\r\nrequire('dotenv').config()\r\n\r\nconst path = require('path');\r\nconst webpack = require('webpack')\r\n\r\nconst NodePolyfillPlugin = require('node-polyfill-webpack-plugin')\r\n\r\nmodule.exports = {\r\n  mode: 'development',\r\n  entry: './src/index.ts',\r\n  output: {\r\n    filename: 'bundle.js',\r\n    path: path.resolve(__dirname, 'dist'),\r\n  },\r\n  plugins: [\r\n    new NodePolyfillPlugin(),\r\n    new webpack.DefinePlugin({\r\n      'process.env': {\r\n        HELLO: JSON.stringify(process.env.HELLO)\r\n      }\r\n    }),\r\n  ]\r\n};\r\n","readmeFilename":"README.md"}