CodeVetter · Repo Unpack · System map
npm/cli
The runtime is a Node.js CLI with a central Npm object coordinating configuration, command dispatch, output, and error handling. Independently packaged workspaces provide dependency-tree management and registry operations. Persistent state spans project manifests and locks, installed modules, caches, logs, and user configuration. Distribution bundles runtime dependencies and builds documentation during packaging.
- package.json exposes npm through bin/npm-cli.js and npx through bin/npx-cli.js; index.js invokes the CLI when executed directly and rejects imports with the removed-programmatic-API error.
- lib/cli.js optionally enables Node's compile cache, then validateEngines installs early syntax-error handlers before loading the asynchronous CLI entry module.
- Npm constructs Config and Display alongside LogFile and Timers; Npm.cmd resolves registered names before dynamically requiring a command implementation.
- execCommandClass handles recursive subcommands, help, workspace support, developer-engine checks, and separate execution branches for commands with definitions versus legacy commands.
- Config stores default, builtin, global, user, project, environment, and CLI layers in a prototype chain; flat options are generated from lower to higher priority.
- Arborist owns actual, virtual, and ideal dependency trees and composes tracker, resolution, loading, rebuilding, reification, and isolated-install behavior through mixins.
- Installation delegates to Arborist and pacote; publishing delegates to libnpmpack, libnpmpublish, npm-registry-fetch, and optional CI OIDC exchange.
- The distributable includes bin, lib, documentation, and man pages with bundled runtime dependencies; prepack builds docs, test invokes TAP, lint invokes ESLint, and supported Node versions are explicitly constrained.