mrkeyoor.com_
Sun 20 Sept 17:52 UTC
npmCLI & Toolingupdated 20 Sept 2026

knip review

Knip 6.32.3 is a static-analysis CLI for unused JavaScript and TypeScript files, exports, dependencies, devDependencies, binaries, unresolved imports, and duplicate exports. It builds a reachability graph from configured entry points, package scripts, workspace manifests, and framework plugins. The current patch recognizes more tsup, Lefthook, WebdriverIO, and Vitest config locations, resolves pnpm subcommands, and fixes nested .gitignore negation. These changes matter because a missed config file or generated entry can turn working code into a false unused report.

Verdict

Knip 6.32.2 installed in 11.9 seconds with 26 packages and 23 MB in our sandbox; current 6.32.3 is worth that CLI footprint when a team will tune entries and review findings. Do not hand --allow-remove-files to unattended CI or expect computed runtime imports to become statically visible.

We installed it

Lab card: what happened when we installed knipScreenshot of knip documentation
Install✓ · 11.9s26 packages on disk · 23 MB
ImportESM import works · require() works · ESM package with exports map
Browsern/acould not be bundled for the browser (Node-only code, most likely)
TypesTypeScript types bundled
Known vulns00 critical · 0 high · 0 moderate · 0 low (npm audit)

Answers from our run

Does knip install cleanly?

Yes. In a fresh container with an empty cache, npm install knip finished in 12 seconds, leaving 26 packages and 23 MB on disk. npm audit reported no known vulnerabilities.

Can knip run in a browser?

Not directly: esbuild could not bundle it for the browser in our run, which normally means it depends on Node built-ins. Use it on the server, or find a browser-targeted alternative.

Does knip work with both ESM and CommonJS?

Yes. Both import 'knip' and require('knip') worked in Node 22 in our run. The package is published as ESM with an exports map.

Does knip include TypeScript types?

Yes, type declarations ship inside the package, so no @types install is needed.

knip or depcheck: which should you use?

Pick depcheck when depcheck 1.x is enough when the question is limited to unused and missing package dependencies. Knip 6.32.2 installed in 11.9 seconds with 26 packages and 23 MB in our sandbox; current 6.32.3 is worth that CLI footprint when a team will tune entries and review findings.

When should you not use knip?

You want an automatic deletion list from a zero-config run. Dynamic imports, filename routes, generators, shell scripts, and external consumers can sit outside Knip's graph.

API stability4/5The core configuration concepts of entry, project, workspaces, plugins, ignore patterns, issue filters, reporters, and fix types remain recognizable through the 6.x line. Patch releases still adjust reachability by recognizing new config filenames, package-manager commands, and ignore behavior. Those fixes can change the result set without changing your config, so pinning Knip and reviewing report diffs is wiser than treating patch output as immutable.
Docs5/5knip.dev explains entries, project files, workspaces, production and strict modes, plugins, issue types, rules, tags, tracing, reporters, caching, and fix behavior with JSON and CLI examples. Plugin pages list their discovered config and entry patterns. The documentation repeatedly warns about file removal, yet complex framework repositories still require readers to understand what creates a graph root rather than copying one universal config.
Maintenance5/5npm published 6.32.3 on August 26, 2026, and GitHub records a push the same day. The repository is unarchived with 12,116 stars and 35 open issues and pull requests. This patch fixes config matching for tsup, Lefthook, WebdriverIO, and Vitest, plus pnpm subcommands and gitignore behavior, showing active work on the exact discovery edges that determine report accuracy.
Ecosystem4/5npm counted 13,869,046 downloads in the latest completed week, and the repository has 12,116 GitHub stars. Knip includes plugins for many test runners, bundlers, frameworks, linters, and workspace tools, which is its main advantage over a plain import walker. Coverage is still convention-based: a new framework release, custom wrapper, or nonstandard config path can precede plugin support and require local configuration.

Use it if

  • Knip 6.32.3 fits a TypeScript or JavaScript repository where dead files, exports, and manifest entries should be reviewed together.
  • A monorepo needs workspace-specific entry and project globs rather than one dependency check at the root.
  • CI should cap known findings, emit GitHub annotations, or trace why one file, export, or dependency is reachable.
  • The team can configure convention-loaded routes, generated files, package exports, and custom tool configs before deleting anything.
Skip it if

Setup reality

We installed Knip 6.32.2 in a fresh Node 22 Bookworm sandbox. npm finished in 11.9 seconds, left 26 packages, and used 23 MB. npm audit reported 0 known vulnerabilities. The package has 13 direct dependencies, no peer dependencies, and 6048 KB unpacked. It requires Node ^20.19.0 or >=22.12.0 and includes TypeScript declarations. Although it declares ESM with an exports map, both require() and ESM import worked in Node 22.23.2.

The registry now serves 6.32.3, so our install figures remain tied to 6.32.2. A browser bundle could not be built in the lab, which fits a Node CLI that walks a project and loads configuration. Run npx knip without --fix first. Correct entry and project globs before treating any unused-file output as actionable. Plugins discover framework conventions, but custom config names and wrapper scripts may still need explicit entries.

In a workspace, configure the root with the . key and child packages with their own globs. Production mode narrows analysis to shipped code, while strict mode checks dependency ownership per workspace. Those are different questions from a normal full-project scan. Use trace-file, trace-export, or trace-dependency when a result looks wrong; the trace usually exposes a missing root more safely than a broad ignore.

Fix mode can edit manifest entries, exports, and source. File removal needs the separate --allow-remove-files flag because it is the risky case. Keep the run on a recoverable branch and review every deletion. Version 6.32.3 improves discovery for several config extensions and nested ignore rules, but static analysis still cannot see a consumer outside the repository or a filename assembled only at runtime.

Patterns

Run a read-only first scan scan-project

npx knip

# Narrow the first review
npx knip --include files,dependencies

The first command reports every enabled issue type. Start narrower when an established repository has many unconfigured roots.

Declare entries and owned source define-roots

{
  "$schema": "https://unpkg.com/knip@6/schema.json",
  "entry": ["src/index.ts", "src/cli.ts", "scripts/*.ts"],
  "project": ["src/**/*.{ts,tsx}", "scripts/**/*.ts"]
}

A project file unreachable from every entry can be reported unused. Add framework-loaded roots that have no import parent.

Give each workspace its roots configure-workspaces

{
  "workspaces": {
    ".": { "entry": ["scripts/*.ts"] },
    "packages/*": {
      "entry": ["src/index.ts"],
      "project": ["src/**/*.ts"]
    }
  }
}

The . key is the root package. Test one child first with knip -W packages/name.

Trace a suspicious finding trace-result

npx knip --trace-file src/legacy.ts
npx knip --trace-export createClient
npx knip --trace-dependency lodash

A trace shows the graph path or missing reachability. Use that evidence before adding a directory-wide ignore.

Check shipped workspace dependencies scan-production

npx knip --production --strict

Production mode excludes development inputs. Strict mode also requires each workspace to declare what it uses.

Suppress generated file reports ignore-generated

{
  "ignoreFiles": ["src/generated/**", "**/*.generated.ts"]
}

ignoreFiles removes unused-file findings for these paths while their imports can still participate in the graph.

Remove selected dependency entries fix-manifest

npx knip --fix --fix-type dependencies

# review package.json and lockfile changes

Shell scripts and external loaders may use a package that imports never reveal. Review the manifest and lockfile diff.

Cap existing CI findings gate-ci

npx knip --reporter github-actions --no-progress --max-issues 25

Exit code 1 means findings exceeded the cap. Exit code 2 means Knip itself failed to run or parse configuration.

Alternatives

PackageRegistryPick it when
depchecknpmdepcheck 1.x is enough when the question is limited to unused and missing package dependencies.
ts-prunenpmUse ts-prune for an older TypeScript-only export scan when files and manifest cleanup are outside scope.
unimportednpmUse unimported when its simpler dead-file and dependency report matches the repository and Knip's plugin system is unnecessary.

More cli & tooling guides

commander · chalk · typescript · esbuild · yargs · click · the whole shelf →

How this guide is made: grounded in the library's documentation, release notes, changelog, and issue history, on a fixed rubric — not a hands-on install of every release. The 50 most-downloaded entries are additionally install-verified in clean containers. Corrections: contact the desk.