Skip to content
VaelJS Blog

vael:os

Operating system target constants and host OS release metadata.

Available in both vjs (vaeljs) and vjs-lite (vaeljs-lite) runtimes. Exposes compilation-target identifiers (platform, arch) using standard cross-platform target names ("darwin" on macOS, "linux", "windows", "amd64", "arm64", "386"), alongside release() for probing host OS release and edition metadata. Installs no globals.

import ... from "vael:os"
Since v0.0.0-alpha.0 vjs (V8) vjs-lite (QuickJS)
Cargo feature: Always enabled in vaeljs-core; vael-os (default) in vaeljs-lite-core
import { arch, platform, release } from "vael:os";
console.log(`Running on ${platform}/${arch}`);
const info = release();
console.log(info.prettyName, info.variant);
functionSince v0.0.0-alpha.2vjs & vjs-lite
export function release(): OsRelease;

Probe the host operating system and return a frozen OsRelease metadata object.

Reads /etc/os-release (falling back to /usr/lib/os-release) on Linux, SystemVersion.plist on macOS, and RtlGetVersion / GetProductInfo on Windows.

Returns
OsRelease — Frozen OsRelease record describing the host operating system.
Exceptions
  • TypeError — when any argument is supplied.
import { release } from "vael:os";
const info = release();
console.log(info.id, info.versionId, info.variant);
interfaceSince v0.0.0-alpha.2vjs & vjs-lite
export interface OsRelease {
  readonly id: string;
  readonly name: string;
  readonly prettyName: string;
  readonly version: string;
  readonly versionId: string;
  readonly codename: string;
  readonly build: string;
  readonly edition: string;
  readonly variant: OsVariant;
}

Frozen operating system release metadata returned by release().

All string fields are always present (defaulting to "" when unavailable on the host OS).

Properties
PropertyTypeDescriptionSince
id readonlystringLowercase operating system identifier (for example "ubuntu", "fedora", "darwin", or "windows").v0.0.0-alpha.2
name readonlystringShort operating system name (for example "Ubuntu", "macOS", or "Windows 11").v0.0.0-alpha.2
prettyName readonlystringHuman-readable display name (for example "Ubuntu 24.04.1 LTS" or "Windows 11 Pro").v0.0.0-alpha.2
version readonlystringFull version string (for example "24.04.1 LTS (Noble Numbat)", "14.5", or "10.0.22631").v0.0.0-alpha.2
versionId readonlystringShort machine-comparable version identifier (for example "24.04", "14.5", or "11").v0.0.0-alpha.2
codename readonlystringRelease codename when available (for example "noble", "bookworm", or "Sonoma"), or "" when unavailable.v0.0.0-alpha.2
build readonlystringBuild identifier or kernel release fallback (for example "rolling", "23F79", or "22631").v0.0.0-alpha.2
edition readonlystringEdition or variant label (for example "Workstation Edition", "Pro", or "Datacenter").v0.0.0-alpha.2
variant readonlyOsVariantHigh-level OS role classification ("desktop", "server", "domain-controller", or "unknown").v0.0.0-alpha.2
typeSince v0.0.0-alpha.2vjs & vjs-lite
export type OsVariant = "desktop" | "server" | "domain-controller" | "unknown";

High-level operating system role or edition classification returned in OsRelease.variant.

constSince v0.0.0-alpha.0vjs & vjs-lite
export const platform:
  | "darwin"
  | "linux"
  | "windows"
  | "freebsd"
  | "netbsd"
  | "aix"
  | "solaris"
  | "illumos"
  | "android"
  | (string & {});

Compilation-target operating system identifier.

Uses standard cross-platform target names ("darwin" on macOS, "linux", "windows", "freebsd", "netbsd", "aix", "solaris", "illumos", "android") rather than legacy names. Constant from build time; performs no runtime host probe.

import { platform } from "vael:os";
const sep = platform === "windows" ? "\\" : "/";
console.log(sep);
constSince v0.0.0-alpha.0vjs & vjs-lite
export const arch:
  | "amd64"
  | "arm64"
  | "386"
  | "arm"
  | "riscv64"
  | "ppc64le"
  | "ppc64"
  | "s390x"
  | "loong64"
  | (string & {});

Compilation-target CPU architecture identifier.

Uses normalized OCI/Go-style short architecture names ("amd64", "arm64", "386", "arm", "riscv64", "ppc64le", "ppc64", "s390x", "loong64"). Constant from build time; performs no runtime host probe.

import { arch } from "vael:os";
if (arch === "amd64") {
console.log("64-bit x86 target");
}