Getting Started
Requirements
Knip v4 requires Node.js v18.6 or higher. Or Bun.
Installation
The recommended way to install Knip is by using your package manager:
npm install -D knip typescript @types/node
pnpm add -D knip typescript @types/node
bun add -D knip typescript @types/node
yarn add -D knip typescript @types/node
Knip uses typescript
and @types/node
as peer dependencies to increase
compatibility with your project (they are likely already in your node_modules
anyway).
Add a knip
script to your package.json
:
{ "name": "my-project", "scripts": { "knip": "knip" }}
Run Knip
Now you can run Knip to lint your project:
npm run knip
pnpm knip
bun knip
yarn knip
Knip will lint your project and output unused files, dependencies and exports.
Without Installation
Alternatively, try Knip without adding it to your project:
npx knip
pnpm dlx knip
bunx knip
ISC License © 2024 Lars Kappert