Skip to content
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

🧩 dependency used only via cli #934

Closed
m-ronchi opened this issue Feb 5, 2025 · 4 comments
Closed

🧩 dependency used only via cli #934

m-ronchi opened this issue Feb 5, 2025 · 4 comments
Labels
discussion Discussion

Comments

@m-ronchi
Copy link

m-ronchi commented Feb 5, 2025

Discuss anything related to Knip

Hi,
I have a dependency (node-pg-migrate) that I use both in dev (inside a package.json script) and in prod (by just including it in the docker image, then I run it using npx node-pg-migrate as a command inside that image).

the problem is that by default, npx knip works, but npx knip --strict reports it as an unused dependencies. if I add it to config ignoreDependencies, then npx knip --strict works but npx knip reports it as Unused item in ignoreDependencies.

which is the correct way to make both commands work?

@m-ronchi m-ronchi added the discussion Discussion label Feb 5, 2025
@webpro
Copy link
Member

webpro commented Feb 6, 2025

Some ideas:

  • The "unused item" is not an error, but a warning (i.e. does not cause non-zero exit code, so won't make CI fail)
  • Use two different configurations, e.g. knip and knip --strict -c knip.strict.json or vice versa
  • Move node-pg-migrate to devDependencies

@m-ronchi
Copy link
Author

m-ronchi commented Feb 6, 2025

Hi, thanks for the ideas.

  1. I am not using it in CI (for now, in this project) but as CLI and visually the output looks the same (with yellow header)
  2. 2 different configs also is not as friendly when I run it manually (also will need to keep them in sync)
  3. node-pg-migrate is actually used in prod, maybe I can transition it to dev when I go back to this particular project.

I think I stay with 1 for now and then try 3 later, but on the knip side, it would be nice a way to declare npm packages' bin as entrypoint (another example: ts-node)

@webpro
Copy link
Member

webpro commented Feb 6, 2025

Re. 2, you could use knip.ts and load one from the other

I'll look into making the output visually more clear

@webpro webpro closed this as completed in dcf5df3 Feb 11, 2025
@webpro
Copy link
Member

webpro commented Feb 11, 2025

🚀 This issue has been resolved in v5.44.0. See Release 5.44.0 for release notes.

Using Knip in a commercial project? Please consider becoming a sponsor.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion Discussion
Projects
None yet
Development

No branches or pull requests

2 participants