{"id":23092988,"url":"https://github.com/crispengari/node-env-types","last_synced_at":"2026-05-04T17:34:46.854Z","repository":{"id":46241655,"uuid":"515167058","full_name":"CrispenGari/node-env-types","owner":"CrispenGari","description":"🌀 a package that generates  typescript types for .env (dotenv) files.","archived":false,"fork":false,"pushed_at":"2024-07-12T08:52:56.000Z","size":197,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-02-17T05:20:21.311Z","etag":null,"topics":["dotenv","env-typescript","env-vars","environment-variables","javascript","nodejs","typescript"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/node-env-types","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/CrispenGari.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-07-18T12:05:18.000Z","updated_at":"2024-07-12T08:52:22.000Z","dependencies_parsed_at":"2023-02-19T15:16:21.571Z","dependency_job_id":null,"html_url":"https://github.com/CrispenGari/node-env-types","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CrispenGari%2Fnode-env-types","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CrispenGari%2Fnode-env-types/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CrispenGari%2Fnode-env-types/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CrispenGari%2Fnode-env-types/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CrispenGari","download_url":"https://codeload.github.com/CrispenGari/node-env-types/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241637288,"owners_count":19994946,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dotenv","env-typescript","env-vars","environment-variables","javascript","nodejs","typescript"],"created_at":"2024-12-16T21:46:10.289Z","updated_at":"2026-05-04T17:34:46.821Z","avatar_url":"https://github.com/CrispenGari.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"### node-env-types\n\n🌀 This package generates the typescript types for environment variables by reading your `.env` file.\n\n\u003cp align=\"center\" width=\"50%\"\u003e\n\u003cimg src=\"https://github.com/CrispenGari/node-env-types/blob/main/logo.png?raw=true\" alt=\"logo\" width=\"200\"/\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://npmjs.com/package/node-env-types\"\u003e\u003cimg src=\"https://img.shields.io/npm/v/node-env-types.svg\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://github.com/crispengari/node-env-types/actions/workflows/main.yml\"\u003e\u003cimg src=\"https://github.com/crispengari/node-env-types/actions/workflows/main.yml/badge.svg\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://github.com/crispengari/node-env-types/actions/workflows/publish.yml\"\u003e\u003cimg src=\"https://github.com/crispengari/node-env-types/actions/workflows/publish.yml/badge.svg\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://github.com/crispengari/node-env-types/blob/main/LICENSE\"\u003e\u003cimg src=\"https://img.shields.io/npm/l/node-env-types.svg?maxAge=2592000\"\u003e\u003c/a\u003e\n\u003ca href=\"https://img.shields.io/node/v/node-env-types.svg?label=node\"\u003e\u003cimg src=\"https://img.shields.io/node/v/node-env-types.svg?label=node\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://npmjs.com/package/node-env-types\"\u003e\u003cimg src=\"https://img.shields.io/npm/dm/node-env-types.svg\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://typescriptlang.org/\"\u003e\u003cimg src=\"https://img.shields.io/badge/language-typescript-blue.svg\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n\u003e **Note:** This package also loads newly added environmental variables when you restart your TypeScript server.\n\u003e\n\u003e ## Table of Contents\n\n- [node-env-types](#node-env-types)\n- [Installation](#installation)\n- [Usage](#usage)\n- [Console output](#console-output)\n- [Parameters](#parameters)\n- [Options](#options)\n- [Common problems](#common-problems)\n- [Languages](#languages)\n- [License](#license)\n\n### Installation\n\nYou can install this package using different package managers as a `dev` dependency.\n\n1. Using `yarn`:\n\n   ```shell\n   yarn add -D node-env-types\n   ```\n\n2. Using `npm`:\n\n   ```shell\n   npm i --save-dev node-env-types\n   ```\n\n3. Using `pnpm`:\n\n   ```shell\n   pnpm add -D node-env-types\n   ```\n\n4. Using `bun`:\n\n   ```shell\n   bun add -d node-env-types\n   ```\n\n### Usage\n\nAfter installing this package you can use it as follows:\n\n```ts\nimport load from 'node-env-types'\nimport process = 'process'\n\nload(process.cwd(), {\n  filename: \".env\", // the path name of the file that contains your environmental variables\n});\n\n```\n\n\u003e We recommend calling `createEnvTypes(rootPath: string, options?: Options)` immediately after your imports. Note that `env-types` will be generated after you run the code for the first time, and you must have an `.env` file or equivalent in your project.\n\n### Console output\n\nThe during generation of `env-types` you can see the output on the console which looks similar to this:\n\n```shell\n *** loading environment variables from C:\\Users\\crisp\\OneDrive\\Documents\\npm\\node-env-types\\.env.\n\n *** created env-types at C:\\Users\\crisp\\OneDrive\\Documents\\npm\\node-env-types\\env.d.ts.\n```\n\n### Parameters\n\nThe `createEnvTypes` function takes two optional parameters:\n\n1. `rootPath` - A string indicating the directory path where your `.env` file is located. The default value is the current working directory (`process.cwd()`).\n\n2. `options` - An optional object of type `Options` containing additional configuration options.\n\n### Options\n\n| Option       | Description                                                                                                                                       | Default Value   |\n| ------------ | ------------------------------------------------------------------------------------------------------------------------------------------------- | --------------- |\n| `filename`   | This is optional, for example you can load your environmental variables from a file called `.env-prod`. If not provided the default will be used. | `.env`          |\n| `outputPath` | This defines the path where you want your declarative TypeScript file to be output during types generation.                                       | `process.cwd()` |\n\n### Common problems\n\n- Sometimes you may not get **auto-completion** even if you have generated the `.d.ts` file. All you have to do is to open your `tsconfig.json` file, go to `includes`, and make sure that your `.d.ts` file is listed there. For example, if your `env.d.ts` file is generated in the root directory, your `includes` array in `tsconfig.json` should look like this:\n\n```json\n{\n  \"compilerOptions\": {},\n  \"include\": [\n    \"./src/**/*.tsx\",\n    \"./src/**/*.ts\",\n    \"src/configs/test.ts\",\n    \"env.d.ts\"\n  ]\n}\n```\n\nAlternatively you can pass an empty array or point to the `root` folder of your project instead of `src` as follows:\n\n```json\n{\n  \"compilerOptions\": {},\n  \"include\": [\"./**/*.tsx\", \"./**/*.ts\", \"src/configs/test.ts\", \"env.d.ts\"]\n}\n```\n\n- Before calling the `createEnvTypes()` functions make sure that you have a `.env` file in your root project of your folder, this is the default file `node-env-types` will be looking for, If environment variables are named differently, make sure that you specify the correct `filename` in the options.\n\n### Languages\n\nThis package is intended to be used by developers who codes in `typescript`.\n\n### License\n\nIn this package I'm using the `MIT` license which reads as follows:\n\n```\nMIT License\n\nCopyright (c) 2022 crispengari\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcrispengari%2Fnode-env-types","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcrispengari%2Fnode-env-types","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcrispengari%2Fnode-env-types/lists"}