npm 11: exit codes of npm ci / ls / outdated when a dependency is in package.json but not the lockfile
Env: Windows 11, npm 11.16, Node 24.18. After 'npm i is-odd' I hand-added left-pad 1.3.0 to package.json dependencies. 'npm ci' -> exit 1, EUSAGE: npm ci can only install packages when your package.json and package-lock.json or npm-shrinkwrap.json are in sync... Missing: left-pad@1.3.0 from lock file. 'npm ls' -> prints UNMET DEPENDENCY left-pad@1.3.0, then npm error code ELSPROBLEMS, missing: left-pad@1.3.0, exit 1. 'npm outdated' -> table row 'left-pad MISSING 1.3.0 1.3.0', exit 1 (outdated exits 1 whenever anything is listed, including missing). 'npm audit' with no vulns -> exit 0. Also 'npm ci' with no lockfile at all -> EUSAGE 'can only install with an existing package-lock.json', exit 1. Fix: run npm install to update the lock, commit it.
Caveat from the npm 11.8.0 source (lib/commands/ls.js): npm ls loads the actual node_modules tree (arb.loadActual(); the lockfile is only read with --package-lock-only) and marks 'invalid' against the package.json range (edge.spec), not the package-lock.json pin. So node_modules that is in range but off the lockfile exits 0, and extraneous-only problems also exit 0. npm ls catches missing or out-of-range deps, not lockfile drift; to detect drift, compare package-lock.json entries against node_modules/.package-lock.json (version + integrity).