Troubleshooting
We can distinguish two types of issues:
Also see the debug and trace options below that can help to troubleshoot issues.
Lint issues reported by Knip
Knip reports lint issues in your codebase. See handling issues to deal with the reported issues.
If Knip reports false positives and you’re considering filing a GitHub issue, please do! It’ll make Knip better for everyone. Please read issue reproduction first.
Exit code 1 indicates a successful run, but lint issues were found.
Exceptions thrown by Knip
Knip may throw an exception, resulting in an unsuccessful run.
See known issues as it may be listed there and a workaround may be
available. If it isn’t clear what’s throwing the exception, try another run with
--debug
to locate the cause of the issue with more details.
If Knip throws an exception and you’re considering filing a GitHub issue, please do! It’ll make Knip better for everyone. Please read issue reproduction first.
Exit code 2 indicates an exception was thrown by Knip.
Debug
To better understand why Knip reports what it does, run it in debug mode by
adding --debug
to the command:
This will give a lengthy output, including:
- Included workspaces
- Used configuration per workspace
- Enabled plugins per workspace
- Glob patterns and options followed by matching file paths
- Plugin config file paths and found dependencies per plugin
- Compiled non-standard source files
Trace
Use --trace
to see where all exports are used. Or be more specific:
- Use
--trace-file [path]
to output this only for the given file. - Use
--trace-export [name]
to output this only for the given export name. - Use both to trace a specific named or default export of a certain file.
This works across re-exports, barrel files and workspaces. Here’s an example screenshot:
It’s like a reversed dependency graph. Instead of traversing imports it goes in the opposite direction and shows where exports are imported.
Legend
Description | |
---|---|
✓ | Contains import and reference to the export |
◯ | Entry file |
Opening an issue
If you want to open an issue, please see issue reproduction.
Understanding Knip
Looking to better understand how Knip works? The entry files and plugins explanations cover two core concepts. After this you might want to check out features like production mode and monorepos & workspaces.
In a more general sense, Why use Knip? explains what Knip can do for you.
Asking for help
If you can’t find your answer in any of the aforementioned resources, feel free to open an issue on GitHub or discuss it in the Discord channel.
ISC License © 2024 Lars Kappert