{"id":13601416,"url":"https://github.com/pablopunk/now-env","last_synced_at":"2025-04-10T18:16:02.192Z","repository":{"id":74867503,"uuid":"113880081","full_name":"pablopunk/now-env","owner":"pablopunk","description":"Use `now.json` environment variables while developing","archived":false,"fork":false,"pushed_at":"2017-12-11T16:13:45.000Z","size":23,"stargazers_count":1,"open_issues_count":0,"forks_count":12,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-24T15:52:35.817Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://npmjs.com/now-env","language":"JavaScript","has_issues":false,"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/pablopunk.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"license.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2017-12-11T16:08:33.000Z","updated_at":"2022-03-12T10:49:23.000Z","dependencies_parsed_at":"2023-07-13T10:15:07.347Z","dependency_job_id":null,"html_url":"https://github.com/pablopunk/now-env","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pablopunk%2Fnow-env","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pablopunk%2Fnow-env/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pablopunk%2Fnow-env/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pablopunk%2Fnow-env/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pablopunk","download_url":"https://codeload.github.com/pablopunk/now-env/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248269707,"owners_count":21075785,"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":[],"created_at":"2024-08-01T18:01:02.447Z","updated_at":"2025-04-10T18:16:02.171Z","avatar_url":"https://github.com/pablopunk.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# now-env\n\n\nWith the help of this package, you can easily set environment variables for the use in development.\n\nIf you're already using a `now.json` file or the `now` key in `package.json`, the `env` sub property will be assigned to `process.env` automatically.\n\nIn addition, you can store secrets locally, that are specific to the development environment.\n\n## Usage\n\nFirstly, install the package from [npm](https://www.npmjs.com/package/now-env):\n\n```bash\nnpm install now-env\n```\n\nAs the last step:\n\n```js\nrequire('now-env')\n```\n\nThat's all, you can now check in `process.env` for you environment variables!\n\n\u003e If your application is running inside [Now](https://zeit.co/now) cloud then this module is not going to do anything and let Now set your environment variables.\n\n### Secrets\n\nMost probably you will want to use [secret keys](https://zeit.co/docs/features/env-and-secrets#securing-env-variables-using-secrets) in your `now.json` file. This module allow you to use them too without worries in development.\n\nCreate a `now.json` with some secret defined as `@secret-name`, similar to:\n\n```json\n{\n  \"env\": {\n    \"SECRET\": \"@my-secret-key\",\n    \"ANOTHER_SECRET\": \"@my-other-secret-key\",\n    \"SECRET_FAIL\": \"@this-is-not-defined\"\n  }\n}\n```\n\nThen create a `now-secrets.json` with the secrets names and values.\n\n```json\n{\n  \"@my-secret-key\": \"keep-it-secret\",\n  \"@my-other-secret-key\": \"keep-it-secret-too\"\n}\n```\n\n\u003e This file must be ignored to actually keep them **secret**.\n\nThen when starting your application `now-env` will read the `now.json` and get the values from `now-secrets.json`. If a environment key can't be found in `now-secrets.json` (or the file doesn't exists) then is going to use the secret name as value, that means if `DB_PASS` is `@db_pass` and you don't define it inside `now-secrets.json` then the value will be `@db_pass`.\n\n### Required Variables\n\nNow supports using the `env` key as an array of required values you'll need to provide when deploying. This module also allow you to use them in development.\n\nCreate a `now.json` with the array, similar to:\n\n```json\n{\n  \"env\": [\n    \"REQUIRED_KEY\",\n    \"REQUIRED_SECRET\"\n  ]\n}\n```\n\nThen create a `now-required.json` with the environment keys and values.\n\n```json\n{\n  \"REQUIRED_KEY\": \"required-value\",\n  \"REQUIRED_SECRET\": \"@required-secret\"\n}\n```\n\n\u003e You can also use secrets, for that you will need to create a `now-secrets.json` too.\n\nThen when starting your application `now-env` will read the `now.json` and get the values from `now-required.json` (and `now-secrets.json`). If a environment key can't be found in `now-required.json` then is going to throw a reference error.\n\n## Migrating from `dotenv`\n\nIf you're already using the `dotenv` module you can switch to `now-env` easily:\n\n1. Create a `now.json` file with the `env` key with every environment variable\n2. Install `now-env`\n3. Change `require('dotenv').config()` with `require('now-env').config()`\n4. That's all!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpablopunk%2Fnow-env","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpablopunk%2Fnow-env","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpablopunk%2Fnow-env/lists"}