require-env-variable

Require specific environment variables. If they don't exist, the application exits

Usage no npm install needed!

<script type="module">
  import requireEnvVariable from 'https://cdn.skypack.dev/require-env-variable';
</script>

README

Install

pnpm add require-env-variable

or

yarn add require-env-variable

or

npm install require-env-variable

Usage

import { requireEnv } from "require-env-variable";

const { NODE_ENV, SSLKEY, SSLCERT, PORT } = requireEnv(
  "NODE_ENV",
  "SSLKEY",
  "SSLCERT",
  "PORT"
);

Returns the environment variables specified, but if any of the environment variables are not defined, the process exits (throws a catchable error).