0
# Package Manager Support
1
2
Multi-package manager support with pluggable architecture. npm-check-updates provides standardized version resolution across different package managers and registries.
3
4
## Capabilities
5
6
### Supported Package Managers
7
8
npm-check-updates supports multiple package managers with consistent API.
9
10
```typescript { .api }
11
type PackageManagerName = 'npm' | 'yarn' | 'pnpm' | 'deno' | 'bun' | 'staticRegistry';
12
13
interface RunOptions {
14
packageManager?: PackageManagerName;
15
}
16
```
17
18
**Supported Managers:**
19
- `'npm'` - Default npm package manager
20
- `'yarn'` - Yarn package manager (v1 and v2+)
21
- `'pnpm'` - pnpm package manager
22
- `'deno'` - Deno runtime with npm dependencies
23
- `'bun'` - Bun runtime and package manager
24
- `'staticRegistry'` - Static registry for offline/cached scenarios
25
26
**Usage Examples:**
27
28
```typescript
29
// Use yarn
30
const result = await ncu({
31
packageManager: 'yarn',
32
upgrade: true
33
});
34
35
// Use pnpm
36
const result = await ncu({
37
packageManager: 'pnpm',
38
upgrade: true
39
});
40
```
41
42
### Package Manager Interface
43
44
Standardized interface that all package managers implement for version resolution.
45
46
```typescript { .api }
47
interface PackageManager {
48
/**
49
* Get the latest stable version
50
*/
51
latest(
52
packageName: string,
53
currentVersion: VersionSpec,
54
options: Options
55
): Promise<VersionSpec | null>;
56
57
/**
58
* Get the newest version including prereleases
59
*/
60
newest(
61
packageName: string,
62
currentVersion: VersionSpec,
63
options: Options
64
): Promise<VersionSpec | null>;
65
66
/**
67
* Greatest version ignoring prerelease suffix
68
*/
69
greatest(
70
packageName: string,
71
currentVersion: VersionSpec,
72
options: Options
73
): Promise<VersionSpec | null>;
74
75
/**
76
* Latest minor version within same major
77
*/
78
minor(
79
packageName: string,
80
currentVersion: VersionSpec,
81
options: Options
82
): Promise<VersionSpec | null>;
83
84
/**
85
* Latest patch version within same minor
86
*/
87
patch(
88
packageName: string,
89
currentVersion: VersionSpec,
90
options: Options
91
): Promise<VersionSpec | null>;
92
93
/**
94
* Latest version within semver range
95
*/
96
semver(
97
packageName: string,
98
currentVersion: VersionSpec,
99
options: Options
100
): Promise<VersionSpec | null>;
101
102
/**
103
* Get version for specific distribution tag
104
*/
105
distTag(
106
packageName: string,
107
tag: string,
108
options: Options
109
): Promise<VersionSpec | null>;
110
}
111
```
112
113
### NPM Package Manager
114
115
Default package manager with full npm registry support.
116
117
```typescript { .api }
118
// NPM-specific configuration
119
interface RunOptions {
120
registry?: string; // Custom npm registry URL
121
registryType?: 'npm'; // Explicit npm registry type
122
}
123
```
124
125
**Features:**
126
- Full npm registry API support
127
- Authentication via `.npmrc`
128
- Scoped package support
129
- Private registry support
130
- Distribution tag support
131
132
**Usage Examples:**
133
134
```bash
135
# CLI usage
136
ncu --packageManager npm --registry https://registry.npmjs.org
137
138
# Programmatic usage
139
await ncu({
140
packageManager: 'npm',
141
registry: 'https://npm.company.com'
142
});
143
```
144
145
### Yarn Package Manager
146
147
Support for both Yarn Classic (v1) and Yarn Modern (v2+).
148
149
```typescript { .api }
150
// Yarn-specific options
151
interface RunOptions {
152
registryType?: 'yarn'; // Use yarn registry configuration
153
}
154
```
155
156
**Features:**
157
- Yarn workspaces support
158
- `.yarnrc` and `.yarnrc.yml` configuration
159
- Yarn-specific version resolution
160
- Private registry support
161
162
**Usage Examples:**
163
164
```bash
165
# CLI usage
166
ncu --packageManager yarn
167
168
# Use yarn registry config
169
ncu --registryType yarn
170
```
171
172
### pnpm Package Manager
173
174
pnpm support with workspace and monorepo functionality.
175
176
```typescript { .api }
177
// pnpm-specific features
178
interface RunOptions {
179
registryType?: 'pnpm'; // Use pnpm registry configuration
180
}
181
```
182
183
**Features:**
184
- pnpm workspaces support
185
- Efficient dependency resolution
186
- `.pnpmrc` configuration support
187
- Strict peer dependency handling
188
189
**Usage Examples:**
190
191
```bash
192
# CLI usage with pnpm
193
ncu --packageManager pnpm
194
195
# Auto-detection via pnpm-lock.yaml
196
ncu --upgrade
197
```
198
199
### Deno Package Manager
200
201
Support for Deno runtime with npm dependencies.
202
203
```typescript { .api }
204
// Deno-specific behavior
205
interface RunOptions {
206
packageManager: 'deno';
207
}
208
```
209
210
**Features:**
211
- Deno npm compatibility layer
212
- No install command (uses deno cache)
213
- ESM-first approach
214
- TypeScript built-in support
215
216
**Usage Examples:**
217
218
```bash
219
# Deno usage
220
ncu --packageManager deno --upgrade
221
```
222
223
### Bun Package Manager
224
225
Support for Bun runtime and package manager.
226
227
```typescript { .api }
228
// Bun-specific configuration
229
interface RunOptions {
230
packageManager: 'bun';
231
}
232
```
233
234
**Features:**
235
- Fast package resolution
236
- npm registry compatibility
237
- Built-in TypeScript support
238
- Efficient installation
239
240
**Usage Examples:**
241
242
```bash
243
# Bun usage
244
ncu --packageManager bun --upgrade
245
```
246
247
### Static Registry
248
249
Offline/cached package manager for static environments.
250
251
```typescript { .api }
252
// Static registry configuration
253
interface RunOptions {
254
packageManager: 'staticRegistry';
255
}
256
```
257
258
**Features:**
259
- Offline operation support
260
- Cached version data
261
- Custom version mappings
262
- Testing and CI environments
263
264
**Usage Examples:**
265
266
```bash
267
# Static registry mode
268
ncu --packageManager staticRegistry
269
```
270
271
### Package Manager Detection
272
273
Automatic package manager detection based on lock files and configuration.
274
275
```typescript { .api }
276
/**
277
* Determine appropriate package manager based on project files
278
* @param options - Configuration options
279
* @returns Detected package manager name
280
*/
281
function determinePackageManager(options: Options): PackageManagerName;
282
```
283
284
**Detection Logic:**
285
1. Check for lock files (`package-lock.json`, `yarn.lock`, `pnpm-lock.yaml`, `bun.lockb`)
286
2. Check `packageManager` field in `package.json`
287
3. Check for manager-specific config files (`.npmrc`, `.yarnrc`, `.pnpmrc`)
288
4. Fall back to npm as default
289
290
**Usage Examples:**
291
292
```typescript
293
// Automatic detection
294
const result = await ncu({
295
upgrade: true
296
// packageManager will be auto-detected
297
});
298
299
// Override detection
300
const result = await ncu({
301
upgrade: true,
302
packageManager: 'yarn' // Force yarn usage
303
});
304
```
305
306
### Registry Configuration
307
308
Configure custom registries and authentication for different package managers.
309
310
```typescript { .api }
311
interface RunOptions {
312
registry?: string; // Custom registry URL
313
registryType?: 'npm' | 'yarn' | 'pnpm'; // Registry configuration source
314
}
315
```
316
317
**Usage Examples:**
318
319
```typescript
320
// Private npm registry
321
await ncu({
322
packageManager: 'npm',
323
registry: 'https://npm.company.com',
324
upgrade: true
325
});
326
327
// Use yarn registry configuration
328
await ncu({
329
packageManager: 'npm',
330
registryType: 'yarn', // Read registry from .yarnrc
331
upgrade: true
332
});
333
```
334
335
### Cross-Platform Support
336
337
Package manager commands are adjusted for different operating systems.
338
339
```typescript { .api }
340
// Platform-specific command handling
341
const cmd = packageManager + (
342
process.platform === 'win32' && packageManager !== 'bun'
343
? '.cmd'
344
: ''
345
);
346
```
347
348
**Platform Adjustments:**
349
- Windows: Adds `.cmd` suffix for npm, yarn, pnpm (but not bun)
350
- Unix/Linux/macOS: Uses command names directly
351
- Environment variable handling for colors and configuration
352
353
**Usage Examples:**
354
355
```bash
356
# Cross-platform compatibility is automatic
357
ncu --upgrade --packageManager yarn
358
# Uses yarn.cmd on Windows, yarn on Unix systems
359
```