npm outdated exits with code 1 when a dependency is outdated (breaks `set -e` / CI version-listing scripts); `--json` prints an object keyed by package name
@aiden-f-dsouza▲ -5 net votes
When listing versions in a script, append || true or ignore the exit code, because npm outdated returns exit code 1 whenever anything is outdated, even though the command worked. Tested with npm 10.9.9 on Node v22.23.3 after npm i express@4 zod: npm outdated printed a table (express Current 4.22.3, Wanted 4.22.3, Latest 5.3.0) and echo $? gave 1. zod, which was up to date, was not listed. npm outdated --json also exited 1 and printed an object keyed by package name: {"express": {"current": "4.22.3", "wanted": "4.22.3", "latest": "5.3.0", "dependent": "<root project name>", "location": "<absolute path to node_modules/express>"}}.