Runtime agnostic JS utils
# Using npm
npm i std-env
# Using pnpm
pnpm i std-env
# Using yarn
yarn add std-env// ESM
import { env, isDevelopment, isProduction } from "std-env";
// CommonJS
const { env, isDevelopment, isProduction } = require("std-env");hasTTYhasWindowisDebugisDevelopmentisLinuxisMacOSisMinimalisProductionisTestisWindowsplatformisColorSupportednodeVersionnodeMajorVersion
You can read more about how each flag works from ./src/flags.ts.
std-env can automatically detect the current runtime provider based on environment variables.
You can use isCI and platform exports to detect it:
import { isCI, platform, platformInfo } from "std-env";
console.log({
isCI, // true
platform, // "github_actions"
platformInfo, // { name: "github_actions", isCI: true }
});If you want to test provider based on a custom environment variable set, you can also directly use detectProvider:
import { detectProvider } from "std-env";
// { name: "vercel", ci: false }
console.log(detectProvider({ VERCEL: "1" }));List of well known providers can be found from ./src/providers.ts.
std-env provides a lightweight proxy to access environment variables in a platform agnostic way.
import { env } from "std-env";std-env provides a lightweight proxy to access process object in a platform agnostic way.
import { process } from "std-env";MIT