Getting Started
Requirements
Knip v5 requires Node.js v18.18.0 or higher. Or Bun.
Want to try Knip without installation? Visit the playground.
Installation
This is the easiest and recommended way to install Knip:
npm init @knip/config
pnpm create @knip/config
bun create @knip/config
yarn create @knip/config
Now you can run Knip to lint your project:
npm run knip
pnpm knip
bun knip
yarn knip
Knip will lint your project and report unused files, dependencies and exports.
You can skip the rest of this page and go to configuration.
Manual
Alternatively, manually install Knip 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. No worries, they’re probably in your
node_modules
already.
Then add a knip
script to your package.json
:
{ "name": "my-project", "scripts": { "knip": "knip" }}
Without installation
To run Knip without adding it to your project:
npx knip
pnpm dlx knip
bunx knip
In this scenario typescript
and @types/node
are expected to be installed
already.
ISC License © 2024 Lars Kappert