-
-
Notifications
You must be signed in to change notification settings - Fork 220
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
💡 an issue with detecting unnecessary files in the monorepo project. #961
Comments
I set up the paths attribute in knip.json, but it still fails to properly recognize the references from monorepo. ![]() |
The recommendation is to use dependencies from Using By the way, there's |
Looked at the implementation again and came to the same conclusion, which I've now tried to document a bit better: https://knip.dev/guides/handling-issues#typescript-path-aliases-in-monorepos ↔ https://knip.dev/reference/faq#why-cant-i-use-path-aliases-to-reference-other-workspaces |
🚀 This issue has been resolved in v5.46.0. See Release 5.46.0 for release notes. Using Knip in a commercial project? Please consider becoming a sponsor. |
Suggest an idea for Knip
I ran into a problem while using knip detection in a monorepo project.

Let me give you an example:
The project comprises two sub-packages, app and infrastructure, where app relies on infrastructure's baseMethod.
When I import the baseMethod() from '@infrastructure/lib/base' in app and run 'knip --production', the file 'packages/infrastructure/lib/base.ts' is flagged as unnecessary.
But when I import the baseMethod from 'infrastructure/lib/base', knip correctly identifies 'packages/infrastructure/lib/base.ts' as a necessary file. I'm wondering, why does the presence of the '@' symbol cause this misidentification?
Here's the layout of the project structure.
The text was updated successfully, but these errors were encountered: