Skip to content

Getting Started

Knip v5 requires Node.js v18.18.0 or higher. Or Bun.

Want to try Knip without installation? Visit the playground.

This is the easiest and recommended way to install Knip:

Terminal window
npm init @knip/config

Now you can run Knip to lint your project:

Terminal window
npm run knip

Knip will lint your project and report unused dependencies, exports and files.

You can skip the rest of this page and go to configuration.

Alternatively, manually install Knip using your package manager:

Terminal window
npm install -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:

package.json
{
"name": "my-project",
"scripts": {
"knip": "knip"
}
}

To run Knip without adding it to your project:

Terminal window
npx knip

In this scenario typescript and @types/node are expected to be installed already.

ISC License © 2024 Lars Kappert