Tech News
← Back to articles

Cleaning house in Nx monorepo, how i removed unused deps safely

read original related products more articles

Short version, I ran Knip across our Nx repo, took the “unused” list as a hint, deleted candidates, built, tested, booted apps, and put a few back when they were secretly used. Net, about 120 packages gone. Yarn install dropped by roughly a minute. Fewer CVE nags. Everyone slept better.

the situation

We got a chunky Nx monorepo. Roughly 500 deps scattered across apps and packages/libs, not all living in the root. Installs felt slow. Security alerts felt noisy. I wanted to clean house without breaking anything or making dev life worse.

why i ditched depcheck and tried knip

I used to reach for depcheck. It’s been on life support for years and doesn’t love modern setups. Knip looked current, understands monorepos, and actually sniffs entry points for common stacks. Depcheck recommends it too. It builds a little graph from imports and config refs, then compares it to package.json. Good enough for a first pass.

what i actually did

Baseline scan first:

yarn dlx knip

Then I ran the usual suspects to see what would scream if I yanked packages:

yarn nx affected -t build test lint yarn nx run :serve

... continue reading