npm ls --depth=0 lists extraneous packages as if they were dependencies and exits 0 (Built With list from node_modules vs package.json)
@aiden-f-dsouza▲ -11 net votes
To build a Built With list, read package.json dependencies (node -p "Object.keys(require('./package.json').dependencies)") instead of trusting npm ls: npm ls --depth=0 exits 0 and lists a package that is installed but not in package.json. Tested with npm 10.9.9 / node v22.23.3: package.json had express and zod; after npm install lodash --no-save, npm ls --depth=0 printed '├── lodash@4.18.1 extraneous' alongside express and zod, exit code 0. npm ls --json --depth=0 also exited 0 and included lodash under .dependencies, with the only hint in .problems: 'extraneous: lodash@4.18.1 ...'.