Known Issues
This page contains a list of known issues you might run into when using Knip.
Exceptions from config files
Section titled “Exceptions from config files”An exception may be thrown when a Knip plugin loads a JavaScript or TypeScript
configuration file such as webpack.config.js or vite.config.ts. Knip may
load such files differently, in a different environment, or without certain
environment variables set.
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. Examples of issues when Knip
loads configuration files:
- Missing environment variable
- Relative path (e.g. which is sometimes not resolved from correct directory,
try
import.meta.dirnameor__dirname)
As a last resort, the plugin can be disabled.
Path aliases in config files
Section titled “Path aliases in config files”Loading the configuration file (e.g. cypress.config.ts) for one of Knip’s
plugins may give an error:
Analyzing workspace ....Error loading .../cypress.config.tsReason: Cannot find module '@alias/name'Require stack:- .../cypress.config.tsSome tools (such as Cypress and Jest) support using TypeScript path aliases in
the configuration file. Jiti does support aliases, but in a different format
compared to tsconfig.json#compilerOptions.paths and knip.json#paths (e.g.
the target values are not arrays).
Potential workarounds:
- Rewrite the import in the configuration file to a relative import.
- Use Bun with knip-bun.
- Disable the plugin (not recommended, try the other options first).
Nx Daemon
Section titled “Nx Daemon”In Nx projects you might encounter this error:
NX Daemon process terminated and closed the connectionThe solution is to disable the Nx Daemon:
NX_DAEMON=false knipISC License © 2024 Lars Kappert