Known Issues
This page contains a list of known issues when running Knip.
TS config files using ESM features
Knip may fail when a plugin tries to load a TypeScript configuration file (e.g.
vite.config.ts
) with an error message like one of these:
This is caused by Knip using jiti to load and execute TypeScript configuration files that contains ESM syntax (such as top-level await), which may incorrectly consider it as CommonJS (instead of not transforming ESM).
Potential workarounds:
- Turn the configuration file from TS into JS (e.g.
vitest.config.ts
→vitest.config.js
). Knip loads modules directly using nativeimport()
calls. This is the recommended workaround. - Add the config file to the list of ignore patterns.
- Disable the plugin.
Use knip --debug
in a monorepo to help locate where the error is coming from.
Issues like #72 and #194 are hopefully fixed in jiti v2. By the way, nothing but love for jiti (it’s awesome).
Reflect.metadata is not a function
Similar to the previous known issue, this is caused through (not by) jiti:
ISC License © 2024 Lars Kappert