# check-react-env

> Check that all used environment variables are set.

Latest version **2.0.0** (published 2024-03-15) · MIT license · 0 weekly downloads

## Install

```sh
npm install check-react-env
pnpm add check-react-env
yarn add check-react-env
bun add check-react-env
```

Provides the commands `find-new-env`, `check-react-env`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.0 |
| Published | 2024-03-15 |
| First published | 2022-12-26 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 8.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Oleksandr Zhukov |
| Maintainers | azhukov |
| Keywords | react, env, environment variables |

## Links

- npm: https://www.npmjs.com/package/check-react-env
- Repository: https://github.com/AleksandrZhukov/check-react-env
- Homepage: https://github.com/AleksandrZhukov/check-react-env#readme
- Issues: https://github.com/AleksandrZhukov/check-react-env/issues
- npm.io page: https://npm.io/package/check-react-env

## Dependencies (4)

- [arg](https://npm.io/package/arg.md) ^5.0.2
- [dotenv](https://npm.io/package/dotenv.md) ^16.0.3
- [fast-glob](https://npm.io/package/fast-glob.md) ^3.2.12
- [picocolors](https://npm.io/package/picocolors.md) ^1.0.0

## Alternatives

- [replicas-cli](https://npm.io/package/replicas-cli.md) — 3.0K weekly downloads
- [env-contract](https://npm.io/package/env-contract.md) — 133 weekly downloads
- [@openveo/api](https://npm.io/package/@openveo/api.md) — 61 weekly downloads
- [@ryniaubenpm2/cumque-error-reiciendis](https://npm.io/package/@ryniaubenpm2/cumque-error-reiciendis.md) — 54 weekly downloads
- [ts-global-type-extra](https://npm.io/package/ts-global-type-extra.md) — 11 weekly downloads

## Recent versions

- 2.0.0 (latest) — 2024-03-15
- 1.2.2 — 2024-03-15
- 1.2.1 — 2023-01-03
- 1.2.0 — 2023-01-03
- 1.1.0 — 2022-12-26
- 1.0.2 — 2022-12-26
- 1.0.1 — 2022-12-26
- 1.0.0 — 2022-12-26

## README

check-react-env
=========

Check that all used environment variables are set.

❗This tool expects that all env variables have same prefix, eg. VITE_

## Installation

```
npm install --save-dev check-react-env
```
or
```
yarn add --dev check-react-env
```

## Usage

### Basic Usage

Add this tool before `start` or `build` scripts of your application into your package.json.
You can also use `pre` script, more details [here](https://docs.npmjs.com/cli/v9/using-npm/scripts#pre--post-scripts).

Specify `--prefix` param based on your env variables.

```
"prestart": "check-react-env --prefix=NX_",
```
Add `--env` param to specify `.env` file to analyze.
```
"prestart": "check-react-env --prefix=NX_ --env=.env.development",
```
Optionally add `--pattern` to specify files to analyze, by default equals `./**/*.{ts,tsx,js,jsx}`, so it checks all `javaScript` and `typeScript` files

```
"prestart": "check-react-env --prefix=NX_ --env=.env.development --pattern='libs/**/*.{ts,tsx,js,jsx}'",
```

## Parameters
<details>
    <summary>Click me</summary>

#### --prefix
* Required: `true`
* Type: `string`

A prefix for env variables, eg. `VITE_` or `NX_`.

#### --env
* Type: `string`

Path to desired `.env` file.

#### --pattern
* Type: `string`
* Default: `./**/*.{ts,tsx,js,jsx}`

Any correct glob pattern. Check [fast-glob#basic-syntax](https://github.com/mrmlnc/fast-glob#basic-syntax) for more details.

#### --ignore-pattern
* Type: `string`

Glob pattern to exclude matches.

</details>

---
<br/>

find-new-env
=========

Helps do not forget to provide example for env variables.

## Usage
Perfectly to add this tool to the pre-commit hook, using for example [husky](https://www.npmjs.com/package/husky)

```
find-new-env --example-env=.env.example --prefix=VITE_ --pattern='app/**/*.{ts,tsx,js,jsx}'
```

## Parameters
<details>
    <summary>Click me</summary>

#### --prefix
* Required: `true`
* Type: `string`

A prefix for env variables, eg. `VITE_` or `NX_`.

#### --example-env
* Required: `true`
* Type: `string`

Path to the file with env examples.

#### --pattern
* Type: `string`
* Default: `./**/*.{ts,tsx,js,jsx}`

Any correct glob pattern. Check [fast-glob#basic-syntax](https://github.com/mrmlnc/fast-glob#basic-syntax) for more details.

#### --ignore-pattern
* Type: `string`

Glob pattern to exclude matches.
</details>

## License

MIT

---
_Source: https://npm.io/package/check-react-env · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
