or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

tessl/npm-pnpm--constants

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

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
npmpkg:npm/@pnpm/constants@1001.3.x

To install, run

npx @tessl/cli install tessl/npm-pnpm--constants@1001.3.0

0

# @pnpm/constants

1

2

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

3

4

## Package Information

5

6

- **Package Name**: @pnpm/constants

7

- **Package Type**: npm

8

- **Language**: TypeScript

9

- **Installation**: `pnpm add @pnpm/constants`

10

11

## Core Imports

12

13

```typescript

14

import {

15

WANTED_LOCKFILE,

16

LOCKFILE_MAJOR_VERSION,

17

LOCKFILE_VERSION,

18

MANIFEST_BASE_NAMES,

19

ENGINE_NAME,

20

WORKSPACE_MANIFEST_FILENAME,

21

getNodeBinLocationForCurrentOS,

22

getDenoBinLocationForCurrentOS,

23

getBunBinLocationForCurrentOS

24

} from "@pnpm/constants";

25

```

26

27

For CommonJS:

28

29

```javascript

30

const {

31

WANTED_LOCKFILE,

32

LOCKFILE_MAJOR_VERSION,

33

LOCKFILE_VERSION,

34

MANIFEST_BASE_NAMES,

35

ENGINE_NAME,

36

WORKSPACE_MANIFEST_FILENAME,

37

getNodeBinLocationForCurrentOS,

38

getDenoBinLocationForCurrentOS,

39

getBunBinLocationForCurrentOS

40

} = require("@pnpm/constants");

41

```

42

43

## Basic Usage

44

45

```typescript

46

import {

47

WANTED_LOCKFILE,

48

LOCKFILE_MAJOR_VERSION,

49

LOCKFILE_VERSION,

50

MANIFEST_BASE_NAMES,

51

getNodeBinLocationForCurrentOS

52

} from "@pnpm/constants";

53

54

// Use lockfile constants

55

console.log(WANTED_LOCKFILE); // "pnpm-lock.yaml"

56

console.log(LOCKFILE_MAJOR_VERSION); // "9"

57

console.log(LOCKFILE_VERSION); // "9.0"

58

59

// Check supported manifest files

60

const isValidManifest = MANIFEST_BASE_NAMES.includes("package.json"); // true

61

62

// Get platform-specific binary locations

63

const nodeBinPath = getNodeBinLocationForCurrentOS(); // "node.exe" on Windows, "bin/node" elsewhere

64

const nodeBinPathLinux = getNodeBinLocationForCurrentOS("linux"); // "bin/node"

65

```

66

67

## Capabilities

68

69

### Lockfile Constants

70

71

Constants related to pnpm lockfile configuration and versioning.

72

73

```typescript { .api }

74

const WANTED_LOCKFILE: string;

75

const LOCKFILE_MAJOR_VERSION: string;

76

const LOCKFILE_VERSION: string;

77

```

78

79

- **WANTED_LOCKFILE**: The filename for pnpm lockfiles (`'pnpm-lock.yaml'`)

80

- **LOCKFILE_MAJOR_VERSION**: Major version of the lockfile format (`'9'`)

81

- **LOCKFILE_VERSION**: Full version of the lockfile format (`'9.0'`)

82

83

### Manifest Constants

84

85

Constants for supported package manifest filenames and workspace configuration.

86

87

```typescript { .api }

88

const MANIFEST_BASE_NAMES: readonly ["package.json", "package.json5", "package.yaml"];

89

const WORKSPACE_MANIFEST_FILENAME: string;

90

```

91

92

- **MANIFEST_BASE_NAMES**: Array of supported package manifest filenames (`['package.json', 'package.json5', 'package.yaml']`)

93

- **WORKSPACE_MANIFEST_FILENAME**: Filename for workspace configuration (`'pnpm-workspace.yaml'`)

94

95

### Engine and Store Constants

96

97

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

98

99

```typescript { .api }

100

const ENGINE_NAME: string;

101

const LAYOUT_VERSION: number;

102

const STORE_VERSION: string;

103

```

104

105

- **ENGINE_NAME**: Platform-specific engine identifier (computed from platform, architecture, and Node.js version)

106

- **LAYOUT_VERSION**: Store layout version (`5`)

107

- **STORE_VERSION**: Store version identifier (`'v10'`)

108

109

### Metadata Directory Constants

110

111

Constants for metadata storage directory names.

112

113

```typescript { .api }

114

const ABBREVIATED_META_DIR: string;

115

const FULL_META_DIR: string;

116

const FULL_FILTERED_META_DIR: string;

117

```

118

119

- **ABBREVIATED_META_DIR**: Directory name for abbreviated metadata (`'metadata-v1.3'`)

120

- **FULL_META_DIR**: Directory name for full metadata (`'metadata-full-v1.3'`) - Currently unused

121

- **FULL_FILTERED_META_DIR**: Directory name for filtered metadata (`'metadata-v1.3'`)

122

123

### Package Field Constants

124

125

Constants for pnpm-specific package.json fields.

126

127

```typescript { .api }

128

const USEFUL_NON_ROOT_PNPM_FIELDS: readonly ["executionEnv"];

129

```

130

131

- **USEFUL_NON_ROOT_PNPM_FIELDS**: Array of useful pnpm fields for non-root packages (`['executionEnv']`)

132

133

### Binary Location Utilities

134

135

Platform-aware utility functions for determining runtime binary locations.

136

137

```typescript { .api }

138

function getNodeBinLocationForCurrentOS(platform?: string): string;

139

function getDenoBinLocationForCurrentOS(platform?: string): string;

140

function getBunBinLocationForCurrentOS(platform?: string): string;

141

```

142

143

These functions return the appropriate binary path for different JavaScript runtimes:

144

145

- **getNodeBinLocationForCurrentOS**: Returns `'node.exe'` on Windows, `'bin/node'` on other platforms

146

- **getDenoBinLocationForCurrentOS**: Returns `'deno.exe'` on Windows, `'deno'` on other platforms

147

- **getBunBinLocationForCurrentOS**: Returns `'bun.exe'` on Windows, `'bun'` on other platforms

148

149

**Parameters:**

150

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

151

152

**Usage Examples:**

153

154

```typescript

155

import {

156

getNodeBinLocationForCurrentOS,

157

getDenoBinLocationForCurrentOS,

158

getBunBinLocationForCurrentOS

159

} from "@pnpm/constants";

160

161

// Use current platform

162

const nodeBin = getNodeBinLocationForCurrentOS(); // Platform-specific

163

164

// Specify platform explicitly

165

const nodeWindows = getNodeBinLocationForCurrentOS("win32"); // "node.exe"

166

const nodeLinux = getNodeBinLocationForCurrentOS("linux"); // "bin/node"

167

const denoBin = getDenoBinLocationForCurrentOS("darwin"); // "deno"

168

const bunBin = getBunBinLocationForCurrentOS("win32"); // "bun.exe"

169

```