CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-pnpm--constants

Essential constants and utility functions used throughout the pnpm package manager ecosystem

Pending

Quality

Pending

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

Overview
Eval results
Files

index.mddocs/

@pnpm/constants

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

Package Information

  • Package Name: @pnpm/constants
  • Package Type: npm
  • Language: TypeScript
  • Installation: pnpm add @pnpm/constants

Core Imports

import {
  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");

Basic Usage

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"

Capabilities

Lockfile Constants

Constants related to pnpm lockfile configuration and versioning.

const WANTED_LOCKFILE: string;
const LOCKFILE_MAJOR_VERSION: string;
const LOCKFILE_VERSION: string;
  • WANTED_LOCKFILE: The filename for pnpm lockfiles ('pnpm-lock.yaml')
  • LOCKFILE_MAJOR_VERSION: Major version of the lockfile format ('9')
  • LOCKFILE_VERSION: Full version of the lockfile format ('9.0')

Manifest Constants

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;
  • MANIFEST_BASE_NAMES: Array of supported package manifest filenames (['package.json', 'package.json5', 'package.yaml'])
  • WORKSPACE_MANIFEST_FILENAME: Filename for workspace configuration ('pnpm-workspace.yaml')

Engine and Store Constants

Constants related to platform identification, store configuration, and versioning.

const ENGINE_NAME: string;
const LAYOUT_VERSION: number;
const STORE_VERSION: string;
  • ENGINE_NAME: Platform-specific engine identifier (computed from platform, architecture, and Node.js version)
  • LAYOUT_VERSION: Store layout version (5)
  • STORE_VERSION: Store version identifier ('v10')

Metadata Directory Constants

Constants for metadata storage directory names.

const ABBREVIATED_META_DIR: string;
const FULL_META_DIR: string;
const FULL_FILTERED_META_DIR: string;
  • ABBREVIATED_META_DIR: Directory name for abbreviated metadata ('metadata-v1.3')
  • FULL_META_DIR: Directory name for full metadata ('metadata-full-v1.3') - Currently unused
  • FULL_FILTERED_META_DIR: Directory name for filtered metadata ('metadata-v1.3')

Package Field Constants

Constants for pnpm-specific package.json fields.

const USEFUL_NON_ROOT_PNPM_FIELDS: readonly ["executionEnv"];
  • USEFUL_NON_ROOT_PNPM_FIELDS: Array of useful pnpm fields for non-root packages (['executionEnv'])

Binary Location Utilities

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:

  • getNodeBinLocationForCurrentOS: Returns 'node.exe' on Windows, 'bin/node' on other platforms
  • getDenoBinLocationForCurrentOS: Returns 'deno.exe' on Windows, 'deno' on other platforms
  • getBunBinLocationForCurrentOS: Returns 'bun.exe' on Windows, 'bun' on other platforms

Parameters:

  • platform (optional): Platform identifier, defaults to process.platform

Usage 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"

Install with Tessl CLI

npx tessl i tessl/npm-pnpm--constants

docs

index.md

tile.json