Skip to content

Discovery flags

Discovery flags control where and how nodehunter walks the filesystem. They apply to scan, size, delete, list, find, why, and inspect.

For output, cache, and confirmation flags, see Global flags.

Quick reference

ShortLongPurpose
-p--pathScan root (overrides [path])
-D--max-depthMax traversal depth
-i--ignoreSkip basename — literal or re:<regex> (repeatable)
-nd--no-ignore-defaultsDisable built-in ignore list
-L--follow-symlinksFollow directory symlinks while scanning

Scan root

bash
nodehunter scan ~/work
nodehunter scan -p ~/work
nodehunter size --path .

-p / --path overrides the optional [path] positional argument. Prefer a scoped directory over your entire home folder.

Depth

bash
nodehunter scan ~/monorepo -D 3
nodehunter size ~/monorepo --max-depth 5

-D / --max-depth caps how deep the walker descends before looking for node_modules. Useful in large monorepos or shallow audits.

Ignore directories

Skip directory basenames during traversal (not full paths). Repeat -i / --ignore for multiple patterns.

Literal names match exactly:

bash
nodehunter scan ~/proj -i vendor -i .turbo

Regex uses the re: prefix:

bash
nodehunter scan ~/proj -i 're:.*cache.*'
nodehunter scan ~/proj -i 're:^\\..*'      # dot-directories
nodehunter size ~/proj -i 're:^dist$' -i vendor

Quote regex patterns in shell — backslashes are often required for ^ and . anchors.

Built-in defaults

These basenames are always skipped unless you pass -nd / --no-ignore-defaults:

Basename
.git
.cache
.pnpm-store
.cargo
.Trash
bash
nodehunter scan ~/proj -nd -i .git   # include .git in traversal rules yourself

On Linux and WSL, absolute prefixes such as /proc, /sys, /dev, and /run are never entered.

bash
nodehunter scan ~/proj -L
nodehunter scan ~/proj --follow-symlinks

-L affects discovery only. Size measurement stays aligned with du and does not follow symlink directories.

Recipes

Audit a monorepo (shallow)

bash
nodehunter size ~/company -D 4 --full

Skip tooling caches but keep everything else

bash
nodehunter scan ~/proj -i .turbo -i .next -i vendor

Ignore all dot-directories except your scan root

bash
nodehunter scan ~/proj -i 're:^\\..*'

CI: JSON discovery on a fixed path

bash
nodehunter size ./repos -D 6 --json --silent

Gotchas

  • Basename only-i vendor skips any directory named vendor, not apps/vendor/foo.
  • Shell escaping — prefer single quotes around re: patterns; test with scan before delete.
  • No matches — widen --path, increase --max-depth, or try --no-ignore-defaults if defaults hide trees you need.
  • Symlinks — discovery with -L may list more paths than size attributes to the same physical storage.