Runtime agnostic JavaScript utility library for environment detection, platform information, CI/CD provider detection, and runtime identification.
npx @tessl/cli install tessl/npm-std-env@3.9.0std-env is a runtime-agnostic JavaScript utility library that provides comprehensive environment detection, platform information, CI/CD provider identification, and runtime detection capabilities. It enables applications to adapt their behavior based on the execution context while maintaining compatibility across Node.js, Deno, Bun, and various edge computing platforms.
npm install std-envimport { env, isNode, isDeno, isCI, provider, platform } from "std-env";For CommonJS:
const { env, isNode, isDeno, isCI, provider, platform } = require("std-env");import { env, isNode, isCI, provider, platform } from "std-env";
// Access environment variables across runtimes
console.log(env.NODE_ENV); // Works in Node.js, Deno, Bun, etc.
// Runtime detection
if (isNode) {
console.log("Running in Node.js");
} else if (isDeno) {
console.log("Running in Deno");
}
// CI/CD provider detection
if (isCI) {
console.log(`Detected CI provider: ${provider}`);
}
// Platform detection
console.log(`Running on: ${platform}`);std-env is built around several key detection systems:
Cross-platform environment variable access that works consistently across Node.js, Deno, Bun, and browser environments.
const env: EnvObject;
const nodeENV: string;
type EnvObject = Record<string, string | undefined>;Boolean flags for detecting various environment states including CI, debug, test, production, and development modes.
const isCI: boolean;
const isDebug: boolean;
const isTest: boolean;
const isProduction: boolean;
const isDevelopment: boolean;
const isMinimal: boolean;
const hasTTY: boolean;
const hasWindow: boolean;
const isColorSupported: boolean;Operating system and platform identification with boolean flags for common platforms.
const platform: string;
const isWindows: boolean;
const isLinux: boolean;
const isMacOS: boolean;
const nodeVersion: string | null;
const nodeMajorVersion: number | null;JavaScript runtime identification following the WinterCG Runtime Keys proposal, with support for Node.js, Deno, Bun, and various edge computing platforms.
const isNode: boolean;
const isDeno: boolean;
const isBun: boolean;
const isFastly: boolean;
const isNetlify: boolean;
const isEdgeLight: boolean;
const isWorkerd: boolean;
const runtime: RuntimeName;
const runtimeInfo: RuntimeInfo | undefined;
type RuntimeName = "workerd" | "deno" | "netlify" | "node" | "bun" | "edge-light" | "fastly" | "";
interface RuntimeInfo { name: RuntimeName; }CI/CD and hosting provider identification with support for 50+ popular services including GitHub Actions, GitLab CI, Vercel, Netlify, and many others.
const provider: ProviderName;
const providerInfo: ProviderInfo;
type ProviderName = "" | "github_actions" | "gitlab" | "vercel" | "netlify" | /* ...50+ more providers */;
interface ProviderInfo {
name: ProviderName;
ci?: boolean;
[meta: string]: any;
}Cross-platform process object access that provides consistent process information across different JavaScript runtimes.
const process: Process;
interface Process extends Partial<Omit<typeof globalThis.process, "versions">> {
env: EnvObject;
versions: Record<string, string>;
}The process object provides a unified interface for accessing process information across Node.js, Deno, Bun, and other JavaScript runtimes.
Core type definitions are included within each capability section above. All types referenced in API signatures are fully defined to ensure complete documentation coverage.