npm audit --omit=dev flags a devDependency's own dev tools: a dependency that ships npm-shrinkwrap.json gets them installed as "extraneous" (not dev), and pruning the lockfile doesn't stick
If a package you install as a devDependency publishes an `npm-shrinkwrap.json` that lists its own dev tools (eslint, js-yaml, ...), npm installs those too, nested under that package. It writes them into your package-lock.json as `"extraneous": true` with no `"dev": true`. Tools that treat "not dev" as production (`npm audit --omit=dev`, lockfile-based scanners) then report their advisories as production. `npm ls --omit=dev` correctly leaves them out. `npm prune --package-lock-only` removes the entries, but the next `npm install` puts them all back, and `npm prune` doesn't remove them from disk. Fix it on the reader side: treat an extraneous entry nested inside a dev-only package as dev.
Setup
- npm 11.19.1, Node 24, Ubuntu.
- A small app repo has 5 production dependencies and a build CLI as a devDependency. The CLI's published package includes an
npm-shrinkwrap.jsonwith 418 entries, 187 of them its own dev tools: eslint 8.x, js-yaml 4.3.1, brace-expansion 2.1.4, glob and others.
What npm does
- It installs the 187 dev tools nested under the CLI, at
node_modules/<cli>/node_modules/.... - It writes them into the app's
package-lock.jsonas:
These entries have no"node_modules/<cli>/node_modules/js-yaml": { "version": "4.3.1", "extraneous": true, ... }"dev": true, even though the CLI itself is marked"dev": true. npm audit --omit=devlists the advisories for js-yaml 4.3.1 and brace-expansion 2.1.4.npm ls --omit=devshows only the 5 real production dependencies.
What doesn't stick
npm prune --package-lock-onlydrops the 187 entries, after whichnpm audit --omit=devfinds 0 vulnerabilities.- The next plain
npm installwrites all 187 entries back. npm prune, run without--package-lock-only, leaves them on disk and writes them back too. The dependency's shrinkwrap re-adds them.
To confirm the cause, read the shrinkwrap:
node -e 'const s=require("./node_modules/<cli>/npm-shrinkwrap.json");let d=0;for(const v of Object.values(s.packages))if(v.dev)d++;console.log(d)'
The count of dev entries there matched the count of extraneous entries in the app's lockfile exactly (187).
What to do instead
- In a scanner that reads
package-lock.json, treat an entry as dev when it hasextraneous: trueand sits under a package path whose own entry isdev: true. Code reached only through a build tool never ships. - Keep counting extraneous entries at the top level, or under a production package: a running app could still load those.
- For a quick manual check, rely on
npm ls --omit=dev, not onnpm audit --omit=dev, to decide what is production.
Conditions
- npm
- 11.19.1
- node
- 24
- os
- Ubuntu 24.04
- observed
- 2026-11-24
- lockfile_version
- 3