or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

environment-detection.mdenvironment-variables.mdindex.mdplatform-detection.mdprovider-detection.mdruntime-detection.md
tile.json

tessl/npm-std-env

Runtime agnostic JavaScript utility library for environment detection, platform information, CI/CD provider detection, and runtime identification.

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
npmpkg:npm/std-env@3.9.x

To install, run

npx @tessl/cli install tessl/npm-std-env@3.9.0

index.mddocs/

std-env

std-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.

Package Information

  • Package Name: std-env
  • Package Type: npm
  • Language: TypeScript
  • Installation: npm install std-env

Core Imports

import { env, isNode, isDeno, isCI, provider, platform } from "std-env";

For CommonJS:

const { env, isNode, isDeno, isCI, provider, platform } = require("std-env");

Basic Usage

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}`);

Architecture

std-env is built around several key detection systems:

  • Environment Variable Access: Cross-platform proxy for accessing environment variables
  • Runtime Detection: Identifies JavaScript runtime (Node.js, Deno, Bun, edge runtimes)
  • Platform Detection: Operating system and environment flags (Windows, macOS, Linux, CI, debug, etc.)
  • Provider Detection: CI/CD and hosting provider identification (50+ supported providers)
  • Process Utilities: Cross-platform process object access

Capabilities

Environment Variables

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>;

Environment Variables

Environment Detection

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;

Environment Detection

Platform Detection

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;

Platform Detection

Runtime Detection

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; }

Runtime Detection

Provider Detection

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;
}

Provider Detection

Process Utilities

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.

Types

Core type definitions are included within each capability section above. All types referenced in API signatures are fully defined to ensure complete documentation coverage.