Skip to content

Known Issues

Known limitations and workarounds for errors during a Knip run.

See handling issues to learn more about dealing with lint issues.

Knip plugins may fail to load a JavaScript or TypeScript configuration file such as webpack.config.js or vite.config.ts:

Terminal window
$ knip
ERROR: Error loading vite.config.ts

Knip exits with code 2 when a plugin config file fails to load. --no-exit-code does not suppress this error.

Knip may load such files differently, in a different environment, with missing environment variables, missing path aliases, etcetera. Use --debug to locate the cause of the issue with more details.

Potential workarounds:

  • For “Cannot find module” and “ENOENT: no such file/dir, open ‘./file’” errors:
    • Install dependencies
    • Use absolute paths, e.g. with path.join() or path.resolve()
    • Set path aliases
  • Set missing environment variable(s), potential solutions:
    • Use a helper package like dotenvx
    • KEY=VAL knip
    • node --env-file .env $(which knip)
  • Run the build script to generate required files.
  • Disable loading the file by overriding the default config for that plugin.
    • Example: vite: { config: [] }
    • In a monorepo, be more specific like so: workspaces: { "packages/lib": { vite: { config: [] } } }
    • If this helps, add the file as an entry file for static analysis.
  • Disable the related plugin.
    • Example: eslint: false
    • In a monorepo, be more specific like so: workspaces: { "packages/lib": { eslint: false } }
    • If this helps, add the file as an entry file for static analysis.
  • As a last resort, ignore the workspace: ignoreWorkspaces: ["packages/lib"].

Loading the configuration file (e.g. cypress.config.ts) for one of Knip’s plugins may give an error:

Terminal window
$ knip
Analyzing workspace ....
Error loading .../cypress.config.ts
Reason: Cannot find module '@alias/name'
Require stack:
- .../cypress.config.ts

Some tools (such as Cypress and Jest) support using TypeScript path aliases in the configuration file.

Potential workarounds:

  • Rewrite the import in the configuration file to a relative import.
  • Inject support with a module like tsx: NODE_OPTIONS="--import tsx" knip
  • Or tsconfig-paths: NODE_OPTIONS="--import tsconfig-paths/register.js" knip
  • Use Bun with knip-bun.
  • See exceptions from config files for more potential workarounds.

In Nx projects you might encounter this error:

Terminal window
NX Daemon process terminated and closed the connection

The solution is to disable the Nx Daemon:

Terminal window
NX_DAEMON=false knip

On machines with low RAM or Windows with Node.js >=22, oxc-parser raw transfer may fail under memory pressure:

Terminal window
RangeError: Array buffer allocation failed

Disable raw transfer to use the normal parser path:

Terminal window
KNIP_DISABLE_RAW_TRANSFER=1 knip

With --cache, configuration or path alias changes may leave results stale. An import may still be reported as unresolved after the missing file is added. Newly added .gitignore files are also not detected automatically.

Run without --cache for fresh results, or delete the cache directory (node_modules/.cache/knip by default, configurable with --cache-location) before running with --cache again.

ISC License © 2026Lars Kappert