npm
$ npm Official Med RiskThe standard CLI bundled with Node.js for managing package.json, package-lock.json, scripts, and registries. Offers rich --json support across ls, outdated, audit, view, install --dry-run, and publish --dry-run, plus --ignore-scripts and npm ci for deterministic installs.
npm install -g npm Direct local Node.js package and script runner tightly bound to node_modules and package-lock.json.
Agent-Readiness Checklist
Local Probe EvidenceCaptured --help excerpt
npm <command>
Usage:
npm install install all the dependencies in your project
npm install <foo> add the <foo> dependency to your project
npm test run this project's tests
npm run <foo> run the script named <foo>
npm <command> -h quick help on <command>
npm -l display usage info for all commands
npm help <term> search for help on <term>
npm help npm more involved overview
All commands:
access, adduser, approve-scripts, audit, bugs, cache, ci,
completion, config, dedupe, deny-scripts, deprecate, diff,
dist-tag, docs, doctor, edit, exec, explain, explore,
find-dupes, fund, get, help, help-search, init, install,
install-ci-test, install-scripts, install-test, link, ll,
login, logout, ls, org, outdated, owner, pack, ping, pkg,
prefix, profile, prune, publish, query, rebuild, repo,
restart, root, run, sbom, search, set, shrinkwrap, stage,
star, stars, start, stop, team, test, token, trust,
undeprecate, uninstall, unpublish, unstar, update, version,
view, whoami
Specify configs in the ini-formatted file:
/Users/pcyan/.npmrc
or on the command line via: npm <command> --key=value
More configuration info: npm help config
Configuration fields: npm help 7 config
[email protected] /opt/homebrew/Cellar/node@24/24.22.0/lib/node_modules/npm FCRS-1.0 6-Dimension Breakdown
Broad --json support across ls, audit, outdated, view, install, and publish, plus --dry-run, --no-color, --no-fund, and -y.
- Native
--jsonand--dry-runon core commands - Deterministic
npm cimode
Supports --dry-run and --ignore-scripts, though default npm install runs arbitrary preinstall/postinstall package scripts unless blocked.
- Lifecycle script execution risk mitigated by
--ignore-scripts
Pre-bundled with every Node.js installation across macOS, Linux, and Windows.
- Bundled by default with Node.js
Universal Node.js ecosystem package manager and script runner (npm run, npm exec).
- Standard registry and workspace tooling
Official GitHub/npm CLI (npm/cli) maintained under Artistic-2.0.
- Official
npm/clirepository
Complete command manuals at docs.npmjs.com and npm help <cmd>.
- Official documentation at docs.npmjs.com/cli
Security, Auth & Guardrails
Reads registry tokens from ~/.npmrc (_authToken) or NPM_TOKEN environment variables; local reads need no auth.
Artistic-2.0 open-source CLI; public npm registry reads and open-source publishing are free.
# npm Agent Rules - Prefer `npm ci --ignore-scripts` over `npm install` on existing repos to avoid lockfile drift and untrusted `postinstall` scripts. - Always preview with `npm publish --dry-run` and never publish without explicit user confirmation.
Agent-Ready Command Recipes
Safe Read-Only Queries
npm ls --depth=0 --json && npm audit --json
Exports top-level installed dependencies and security advisories as structured JSON.
npm install --dry-run --json
Simulates dependency resolution and reports planned adds/updates in JSON.
Controlled Writes & Previews
npm ci --ignore-scripts --no-audit --no-fund
Reproduces node_modules strictly from package-lock.json while blocking postinstall script execution.
Strengths for Agents
- +
--jsonand--dry-runwork consistently across inspection, install, and publish flows. - + Bundled with Node.js everywhere with
npm cifor deterministic lockfile installs.
Caveats & Pitfalls
- !
npm installexecutespostinstalllifecycle scripts by default unless--ignore-scriptsis passed. - ! Slower disk installs and looser node_modules isolation than
pnpm.