Essential constants and utility functions used throughout the pnpm package manager ecosystem
npx @tessl/cli install tessl/npm-pnpm--constants@1001.3.0@pnpm/constants provides essential constants and utility functions used throughout the pnpm package manager ecosystem. It serves as a centralized location for shared constants that ensure consistency across pnpm's modular architecture, including lockfile versioning, workspace manifest filenames, store layout versions, and platform-specific binary locations.
pnpm add @pnpm/constantsimport {
WANTED_LOCKFILE,
LOCKFILE_MAJOR_VERSION,
LOCKFILE_VERSION,
MANIFEST_BASE_NAMES,
ENGINE_NAME,
WORKSPACE_MANIFEST_FILENAME,
getNodeBinLocationForCurrentOS,
getDenoBinLocationForCurrentOS,
getBunBinLocationForCurrentOS
} from "@pnpm/constants";For CommonJS:
const {
WANTED_LOCKFILE,
LOCKFILE_MAJOR_VERSION,
LOCKFILE_VERSION,
MANIFEST_BASE_NAMES,
ENGINE_NAME,
WORKSPACE_MANIFEST_FILENAME,
getNodeBinLocationForCurrentOS,
getDenoBinLocationForCurrentOS,
getBunBinLocationForCurrentOS
} = require("@pnpm/constants");import {
WANTED_LOCKFILE,
LOCKFILE_MAJOR_VERSION,
LOCKFILE_VERSION,
MANIFEST_BASE_NAMES,
getNodeBinLocationForCurrentOS
} from "@pnpm/constants";
// Use lockfile constants
console.log(WANTED_LOCKFILE); // "pnpm-lock.yaml"
console.log(LOCKFILE_MAJOR_VERSION); // "9"
console.log(LOCKFILE_VERSION); // "9.0"
// Check supported manifest files
const isValidManifest = MANIFEST_BASE_NAMES.includes("package.json"); // true
// Get platform-specific binary locations
const nodeBinPath = getNodeBinLocationForCurrentOS(); // "node.exe" on Windows, "bin/node" elsewhere
const nodeBinPathLinux = getNodeBinLocationForCurrentOS("linux"); // "bin/node"Constants related to pnpm lockfile configuration and versioning.
const WANTED_LOCKFILE: string;
const LOCKFILE_MAJOR_VERSION: string;
const LOCKFILE_VERSION: string;'pnpm-lock.yaml')'9')'9.0')Constants for supported package manifest filenames and workspace configuration.
const MANIFEST_BASE_NAMES: readonly ["package.json", "package.json5", "package.yaml"];
const WORKSPACE_MANIFEST_FILENAME: string;['package.json', 'package.json5', 'package.yaml'])'pnpm-workspace.yaml')Constants related to platform identification, store configuration, and versioning.
const ENGINE_NAME: string;
const LAYOUT_VERSION: number;
const STORE_VERSION: string;5)'v10')Constants for metadata storage directory names.
const ABBREVIATED_META_DIR: string;
const FULL_META_DIR: string;
const FULL_FILTERED_META_DIR: string;'metadata-v1.3')'metadata-full-v1.3') - Currently unused'metadata-v1.3')Constants for pnpm-specific package.json fields.
const USEFUL_NON_ROOT_PNPM_FIELDS: readonly ["executionEnv"];['executionEnv'])Platform-aware utility functions for determining runtime binary locations.
function getNodeBinLocationForCurrentOS(platform?: string): string;
function getDenoBinLocationForCurrentOS(platform?: string): string;
function getBunBinLocationForCurrentOS(platform?: string): string;These functions return the appropriate binary path for different JavaScript runtimes:
'node.exe' on Windows, 'bin/node' on other platforms'deno.exe' on Windows, 'deno' on other platforms'bun.exe' on Windows, 'bun' on other platformsParameters:
platform (optional): Platform identifier, defaults to process.platformUsage Examples:
import {
getNodeBinLocationForCurrentOS,
getDenoBinLocationForCurrentOS,
getBunBinLocationForCurrentOS
} from "@pnpm/constants";
// Use current platform
const nodeBin = getNodeBinLocationForCurrentOS(); // Platform-specific
// Specify platform explicitly
const nodeWindows = getNodeBinLocationForCurrentOS("win32"); // "node.exe"
const nodeLinux = getNodeBinLocationForCurrentOS("linux"); // "bin/node"
const denoBin = getDenoBinLocationForCurrentOS("darwin"); // "deno"
const bunBin = getBunBinLocationForCurrentOS("win32"); // "bun.exe"