{"id":29282861,"url":"https://github.com/aetherinox/node-noxenv","last_synced_at":"2025-07-05T18:13:09.660Z","repository":{"id":239140415,"uuid":"786760524","full_name":"Aetherinox/node-noxenv","owner":"Aetherinox","description":"NodeJS package which allows you to declare environment variables.","archived":false,"fork":false,"pushed_at":"2025-06-16T03:48:29.000Z","size":143,"stargazers_count":3,"open_issues_count":4,"forks_count":1,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-07-03T11:11:30.642Z","etag":null,"topics":["env","environment","environment-variable","environment-variables","node","nodejs","noxenv","npm","npm-package","process"],"latest_commit_sha":null,"homepage":"https://npmjs.com/package/@aetherinox/noxenv","language":"JavaScript","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/Aetherinox.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"custom":["https://buymeacoffee.com/aetherinox"]}},"created_at":"2024-04-15T08:52:07.000Z","updated_at":"2025-05-30T02:31:28.000Z","dependencies_parsed_at":"2024-05-10T09:45:19.402Z","dependency_job_id":null,"html_url":"https://github.com/Aetherinox/node-noxenv","commit_stats":null,"previous_names":["aetherinaux/noxenv","aetherinox/node-noxenv"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/Aetherinox/node-noxenv","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Aetherinox%2Fnode-noxenv","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Aetherinox%2Fnode-noxenv/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Aetherinox%2Fnode-noxenv/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Aetherinox%2Fnode-noxenv/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Aetherinox","download_url":"https://codeload.github.com/Aetherinox/node-noxenv/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Aetherinox%2Fnode-noxenv/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263783037,"owners_count":23510738,"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":["env","environment","environment-variable","environment-variables","node","nodejs","noxenv","npm","npm-package","process"],"created_at":"2025-07-05T18:13:04.411Z","updated_at":"2025-07-05T18:13:09.646Z","avatar_url":"https://github.com/Aetherinox.png","language":"JavaScript","readme":"\u003cdiv align=\"center\"\u003e\n\u003ch6\u003eManage package.json environment variables\u003c/h6\u003e\n\u003ch1\u003e🔅 node-noxenv 🔅\u003c/h1\u003e\n\n\u003cbr /\u003e\n\n\u003cp\u003eSet and get environment variables in your node project package.json, across different platforms\u003c/p\u003e\n\n\u003cbr /\u003e\n\n\u003cdiv align=\"center\"\u003e\n\n\u003c!-- prettier-ignore-start --\u003e\n[![Version][github-version-img]][github-version-uri]\n[![Version][npm-version-img]][npm-version-uri]\n[![Build Status][github-tests-img]][github-tests-uri]\n[![Downloads][github-downloads-img]][github-downloads-uri]\n[![Size][github-size-img]][github-size-img]\n[![Last Commit][github-commit-img]][github-commit-img]\n[![Contributors][contribs-all-img]](#contributors-)\n\u003c!-- prettier-ignore-end --\u003e\n\n\u003c/div\u003e\n\n\u003c/div\u003e\n\n---\n\n\u003cbr /\u003e\n\n- [About](#about)\n- [Installation](#installation)\n- [Usage](#usage)\n- [noxenv vs noxenv-shell](#noxenv-vs-noxenv-shell)\n- [Windows Users](#windows-users)\n- [Troubleshooting](#troubleshooting)\n  - [Error: 'noxenv' is not recognized as an internal or external command](#error-noxenv-is-not-recognized-as-an-internal-or-external-command)\n- [Contributors ✨](#contributors-)\n\n\u003cbr /\u003e\n\n---\n\n\u003cbr /\u003e\n\n## About\n\n`noxenv` is a NodeJS package which allows you to pass environment variables to your project, including run commands within your `package.json`.\n\n\u003cbr /\u003e\n\nMost Windows-based command prompts / terminals will have issues when you attempt to set env variables utilizing `NODE_ENV=production`; unless you are using [Bash on Windows][win-bash]. Coupled with the issue that Windows and *NIX have different ways of utilizing env variables such as:\n\n- Windows: `%ENV_VAR%`\n- *NIX: `$ENV_VAR`\n\n\u003cbr /\u003e\n\n`noxenv` gives you the ability to have a single command at your disposal; without the hassle of worrying about different platforms. Specify your env variable as you would on *nix, and noxenv will take care of the conversion for Windows users.\n\n\u003cbr /\u003e\n\n\u003e [!NOTE]\n\u003e `noxenv` only supports Node.js v16 and higher. As of May 2025, NodeJS v15 has been sunset.\n\n\u003cbr /\u003e\n\n---\n\n\u003cbr /\u003e\n\n## Installation\n\nThis module is distributed via [npm][npm] which is bundled with [node][node]. To utilize this moduke, add it to your project's `package.json` -\u003e `devDependencies`:\n\n```json\n\"devDependencies\": {\n    \"@aetherinox/noxenv\": \"^1.1.0\"\n},\n```\n\n\u003cbr /\u003e\n\nTo install it via the npm command-line as a `devDependency`:\n\n```\nnpm i --save-dev @aetherinox/noxenv\n```\n\n\u003cbr /\u003e\n\n---\n\n\u003cbr /\u003e\n\n## Usage\n\nSome examples have been provided below to show various ways of using noxenv:\n\n\u003cbr /\u003e\n\n```json\n{\n    \"scripts\": {\n        \"build\": \"noxenv NODE_ENV=production webpack --config build/webpack.config.js\",\n        \"build-rollup\": \"noxenv NODE_ENV=production rollup -c\",\n        \"development\": \"noxenv NODE_ENV=development npm start\",\n        \"production\": \"noxenv NODE_ENV=production SERVER_IP=http://127.0.0.1 npm start\",\n        \"test\": \"noxenv BABEL_ENV=test jest test/app\",\n        \"start-dev\": \"noxenv NODE_ENV=development PORT_ENV=2350 npm run build \u0026\u0026 node dist/src/main.js\",\n        \"openssl-legacy\": \"noxenv NODE_OPTIONS=\\\"--openssl-legacy-provider\\\" tsc -p tsconfig.json\"\n    }\n}\n```\n\n\u003cbr /\u003e\n\nInside your module, you can call these env variables with something similar to the below example:\n\n```javascript\nconst TEST = { api: \"f4dcc990-f8f7-4343-b852-a2065b4445d5\" };\nconst PROD = { api: \"d1ac1eb8-7194-4095-8976-04be09378611\" };\n\nlet target;\nif (process.env.BABEL_ENV === \"development\") {\n    target = TEST;\n} else if (process.env.BABEL_ENV === \"production\") {\n    target = PROD;\n}\n\nconsole.log(`Running ${process.env.BABEL_ENV} mode; API key is ${target}`);\n```\n\n\u003cbr /\u003e\n\nIn the above example, variables such as `BABEL_ENV` will be set by `noxenv`.  You can also set multiple environment variables at a time:\n\n```json\n{\n    \"scripts\": {\n        \"release-beta\": \"noxenv RELEASE=beta ENV=dev PORT=7732 npm run release \u0026\u0026 npm run start\",\n    }\n}\n```\n\n\u003cbr /\u003e\n\nAdditionally; you can split the command into several actions, or separate the env variable declarations from the actual command execution; note the following example:\n\n```json\n{\n    \"scripts\": {\n        \"parent\": \"noxenv USER_NAME=\\\"Joe\\\" npm run child\",\n        \"child\": \"noxenv-shell \\\"echo Hello $USER_NAME\\\"\"\n    }\n}\n```\n\n\u003cbr /\u003e\n\nIn the above example, `child` stores the actual command to execute, and `parent` sets the env variable that is going to be used. In this case, `Joe` is the user we want to say hello to, so we store Joe's name in within the env variable `USER_NAME`, and then at the end of `parent`, we call `child` which does the actual greeting.\n\n\u003cbr /\u003e\n\nThis means that you only need to call `parent`, and both will be ran. Additionally, it also means that you can also call the env variable using `$USER_NAME` on Windows, even though the typical Windows syntax is `%USER_NAME%`.\n\n\u003cbr /\u003e\n\nIf you wish to pass a JSON string (such as when using [ts-loader]), you may do the following:\n\n\u003cbr /\u003e\n\n```json\n{\n    \"scripts\": {\n        \"test\": \"noxenv TS_NODE_COMPILER_OPTIONS={\\\\\\\"module\\\\\\\":\\\\\\\"commonjs\\\\\\\"} mocha --config ./test.js\"\n    }\n}\n```\n\n\u003cbr /\u003e\n\nTake note of the `triple backslashes` `(\\\\\\)` before `double quotes` `(\")` and the absence of `single quotes` `(')`. This syntax is critical in order for the env var to work on both on Windows and *NIX.\n\n\u003cbr /\u003e\n\n---\n\n\u003cbr /\u003e\n\n## noxenv vs noxenv-shell\n\n`noxenv` provides two binary files: `noxenv` and `noxenv-shell`.\n\n\u003cbr /\u003e\n\n| Binary | Description |\n| --- | --- |\n| `noxenv` | Executes commands utilizing [`cross-spawn`][cross-spawn] |\n| `noxenv-shell` | Executes commands utilizing node's `shell`. Useful when you need an env var to be set across an entire shell script, rather than a single command. Also used when wanting to pass a command that contains special shell characters that you need interpreted |\n\n\u003cbr /\u003e\n\nIf you want to have the env variable apply to several commands in a series, you will need to wrap them in quotes and use `noxenv-shell`, instead of `noxenv`.\n\n```json\n{\n    \"scripts\": {\n        \"salutation\": \"noxenv-shell SALUTATION=Howdy NAME=Aetherinox \\\"echo $SALUTATION \u0026\u0026 echo $NAME\\\"\"\n    }\n}\n```\n\n\u003cbr /\u003e\n\nIf you need to handle [signal events](https://nodejs.org/api/process.html#process_signal_events) within your project, use `noxenv-shell`. An example use for this is when you want to capture the `SIGINT` event invoked by pressing `Ctrl + C` within your command-line interface.\n\n\u003cbr /\u003e\n\n---\n\n\u003cbr /\u003e\n\n## Windows Users\n\nNote that `npm` uses `cmd` by default and doesn't support command substitution, so if you want to leverage that, then you need to update your `.npmrc` and set `script-shell` to powershell.\n\n\u003cbr /\u003e\n\n---\n\n\u003cbr /\u003e\n\n## Troubleshooting\n\nReview the following list of issues and corrective measures you can take to address the issues:\n\n\u003cbr /\u003e\n\n### Error: 'noxenv' is not recognized as an internal or external command\n\nIf you get the following error when running a NodeJS script which utilizes noxenv:\n\n```shell\n'noxenv' is not recognized as an internal or external command,\noperable program or batch file.\n```\n\n\u003cbr /\u003e\n\nEnsure you install it first locally as a dev dependency:\n\n```shell\nnpm i --save-dev @aetherinox/noxenv\n```\n\n\u003cbr /\u003e\n\n---\n\n\u003cbr /\u003e\n\n## Contributors ✨\n\nWe are always looking for contributors. If you feel that you can provide something useful to this project, then we'd love to review your suggestion. Before submitting your contribution, please review the following resources:\n\n- [Pull Request Procedure](.github/PULL_REQUEST_TEMPLATE.md)\n- [Contributor Policy](CONTRIBUTING.md)\n\n\u003cbr /\u003e\n\nWant to help but can't write code?\n\n- Review [active questions by our community](https://github.com/Aetherinox/node-noxenv/labels/❔%20Question) and answer the ones you know.\n\n\u003cbr /\u003e\n\nThe following people have helped keep this project going:\n\n\u003cbr /\u003e\n\n\u003cdiv align=\"center\"\u003e\n\n\u003c!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section --\u003e\n[![Contributors][contribs-all-img]](#contributors-)\n\u003c!-- ALL-CONTRIBUTORS-BADGE:END --\u003e\n\n\u003c!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section --\u003e\n\u003c!-- prettier-ignore-start --\u003e\n\u003c!-- markdownlint-disable --\u003e\n\u003ctable\u003e\n  \u003ctbody\u003e\n    \u003ctr\u003e\n      \u003ctd align=\"center\" valign=\"top\"\u003e\u003ca href=\"https://github.com/Aetherinox\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/118329232?v=4\u0026s=40\" width=\"80px;\" alt=\"Aetherinox\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eAetherinox\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/Aetherinox/noxenv/commits?author=Aetherinox\" title=\"Code\"\u003e💻\u003c/a\u003e \u003ca href=\"#projectManagement-Aetherinox\" title=\"Project Management\"\u003e📆\u003c/a\u003e\u003c/td\u003e\n    \u003c/tr\u003e\n  \u003c/tbody\u003e\n\u003c/table\u003e\n\u003c/div\u003e\n\u003c!-- markdownlint-restore --\u003e\n\u003c!-- prettier-ignore-end --\u003e\n\u003c!-- ALL-CONTRIBUTORS-LIST:END --\u003e\n\n\u003cbr /\u003e\n\u003cbr /\u003e\n\n\u003c!-- prettier-ignore-start --\u003e\n\u003c!-- markdownlint-disable --\u003e\n\n\u003cbr /\u003e\n\n---\n\n\u003cbr /\u003e\n\n\u003c!-- prettier-ignore-start --\u003e\n\u003c!-- markdownlint-disable --\u003e\n\n\u003c!-- BADGE \u003e GENERAL --\u003e\n  [general-npmjs-uri]: https://npmjs.com\n  [general-nodejs-uri]: https://nodejs.org\n  [general-npmtrends-uri]: https://npmtrends.com/@aetherinox/noxenv\n\n\u003c!-- BADGE \u003e VERSION \u003e GITHUB --\u003e\n  [github-version-img]: https://img.shields.io/github/v/tag/aetherinox/node-noxenv?logo=GitHub\u0026label=Version\u0026color=ba5225\n  [github-version-uri]: https://github.com/Aetherinox/node-noxenv/releases\n\n\u003c!-- BADGE \u003e VERSION \u003e NPMJS --\u003e\n  [npm-version-img]: https://img.shields.io/npm/v/@aetherinox/noxenv?logo=npm\u0026label=Version\u0026color=ba5225\n  [npm-version-uri]: https://npmjs.com/package/@aetherinox/noxenv\n\n\u003c!-- BADGE \u003e VERSION \u003e PYPI --\u003e\n  [pypi-version-img]: https://img.shields.io/pypi/v/noxenv\n  [pypi-version-uri]: https://pypi.org/project/noxenv/\n\n\u003c!-- BADGE \u003e LICENSE \u003e MIT --\u003e\n  [license-mit-img]: https://img.shields.io/badge/MIT-FFF?logo=creativecommons\u0026logoColor=FFFFFF\u0026label=License\u0026color=9d29a0\n  [license-mit-uri]: https://github.com/Aetherinox/node-noxenv/blob/main/LICENSE\n\n\u003c!-- BADGE \u003e GITHUB \u003e DOWNLOAD COUNT --\u003e\n  [github-downloads-img]: https://img.shields.io/github/downloads/Aetherinox/node-noxenv/total?logo=github\u0026logoColor=FFFFFF\u0026label=Downloads\u0026color=376892\n  [github-downloads-uri]: https://github.com/Aetherinox/node-noxenv/releases\n\n\u003c!-- BADGE \u003e NPMJS \u003e DOWNLOAD COUNT --\u003e\n  [npmjs-downloads-img]: https://img.shields.io/npm/dw/%40aetherinox%2Fnoxenv?logo=npm\u0026\u0026label=Downloads\u0026color=376892\n  [npmjs-downloads-uri]: https://npmjs.com/package/@aetherinox/noxenv\n\n\u003c!-- BADGE \u003e GITHUB \u003e DOWNLOAD SIZE --\u003e\n  [github-size-img]: https://img.shields.io/github/repo-size/Aetherinox/node-noxenv?logo=github\u0026label=Size\u0026color=59702a\n  [github-size-uri]: https://github.com/Aetherinox/node-noxenv/releases\n\n\u003c!-- BADGE \u003e NPMJS \u003e DOWNLOAD SIZE --\u003e\n  [npmjs-size-img]: https://img.shields.io/npm/unpacked-size/@aetherinox/noxenv/latest?logo=npm\u0026label=Size\u0026color=59702a\n  [npmjs-size-uri]: https://npmjs.com/package/@aetherinox/noxenv\n\n\u003c!-- BADGE \u003e CODECOV \u003e COVERAGE --\u003e\n  [codecov-coverage-img]: https://img.shields.io/codecov/c/github/Aetherinox/node-noxenv?token=MPAVASGIOG\u0026logo=codecov\u0026logoColor=FFFFFF\u0026label=Coverage\u0026color=354b9e\n  [codecov-coverage-uri]: https://codecov.io/github/Aetherinox/node-noxenv\n\n\u003c!-- BADGE \u003e ALL CONTRIBUTORS --\u003e\n  [contribs-all-img]: https://img.shields.io/github/all-contributors/Aetherinox/node-noxenv?logo=contributorcovenant\u0026color=de1f6f\u0026label=contributors\n  [contribs-all-uri]: https://github.com/all-contributors/all-contributors\n\n\u003c!-- BADGE \u003e GITHUB \u003e BUILD \u003e NPM --\u003e\n  [github-build-img]: https://img.shields.io/github/actions/workflow/status/Aetherinox/node-noxenv/package-release.yml?logo=github\u0026logoColor=FFFFFF\u0026label=Build\u0026color=%23278b30\n  [github-build-uri]: https://github.com/Aetherinox/node-noxenv/actions/workflows/package-release.yml\n\n\u003c!-- BADGE \u003e GITHUB \u003e BUILD \u003e Pypi --\u003e\n  [github-build-pypi-img]: https://img.shields.io/github/actions/workflow/status/Aetherinox/node-noxenv/release-pypi.yml?logo=github\u0026logoColor=FFFFFF\u0026label=Build\u0026color=%23278b30\n  [github-build-pypi-uri]: https://github.com/Aetherinox/node-noxenv/actions/workflows/release-pypi.yml\n\n\u003c!-- BADGE \u003e GITHUB \u003e TESTS --\u003e\n  [github-tests-img]: https://img.shields.io/github/actions/workflow/status/Aetherinox/node-noxenv/package-tests.yml?logo=github\u0026label=Tests\u0026color=2c6488\n  [github-tests-uri]: https://github.com/Aetherinox/node-noxenv/actions/workflows/package-tests.yml\n\n\u003c!-- BADGE \u003e GITHUB \u003e COMMIT --\u003e\n  [github-commit-img]: https://img.shields.io/github/last-commit/Aetherinox/node-noxenv?logo=conventionalcommits\u0026logoColor=FFFFFF\u0026label=Last%20Commit\u0026color=313131\n  [github-commit-uri]: https://github.com/Aetherinox/node-noxenv/commits/main/\n\n\u003c!-- prettier-ignore-end --\u003e\n\u003c!-- markdownlint-restore --\u003e\n","funding_links":["https://buymeacoffee.com/aetherinox"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faetherinox%2Fnode-noxenv","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faetherinox%2Fnode-noxenv","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faetherinox%2Fnode-noxenv/lists"}