@@ -314,29 +314,28 @@ control, security and stability.
314
314
### Unlisted binaries
315
315
316
316
Binaries are executable Node.js scripts. Some npm packages, when installed, add
317
- one or more executable files to use from scripts in ` package.json ` . Examples
317
+ one or more executable files to be used from scripts in ` package.json ` . Examples
318
318
include TypeScript that comes with the ` tsc ` binary, ESLint comes with ` eslint ` ,
319
319
Next.js with ` next ` , and so on.
320
320
321
321
Knip detects such binaries in scripts and checks whether there's a package
322
322
installed that includes that binary. It looks up the ` bin ` field in the
323
323
` package.json ` file of installed packages. If it doesn't find it, it will be
324
- reported as an unlisted binary as there is no package listed that contains it.
324
+ reported as an unlisted binary as there is no package that contains it.
325
325
326
326
Binaries that are installed on the OS already and thus likely not meant to be
327
327
installed from npm are not reported as unlisted (details: [ list of ignored
328
328
binaries in source] [ 30 ] ).
329
329
330
- ### Missing binaries
330
+ #### Missing binaries
331
331
332
- In case unused (dev) dependencies look like a match against unlisted binaries,
333
- then this might be caused by ` node_modules ` not containing the packages. And
334
- this might have been caused by either the way your package manager installs
335
- dependencies and binaries, or by not running Knip from the root of the
336
- repository.
332
+ An unused dependency and an unlisted binary with the same name indicates
333
+ ` node_modules ` not containing the relevant package. And this might be caused by
334
+ either the way your package manager installs dependencies and binaries, or by
335
+ not running Knip from the root of the repository.
337
336
338
- ** Solution** : run Knip from the project root. From there you can [ lint
339
- individual workspaces ] [ 31 ] .
337
+ ** Solution** : run Knip from the project root. If needed, [ lint workspaces
338
+ individually ] [ 31 ] .
340
339
341
340
Sometimes binaries and how they're reported can be a bit confusing. See this
342
341
example:
@@ -357,8 +356,15 @@ This example works fine without anything reported, as the `@commitlint/cli`
357
356
package includes the ` commitlint ` binary. However, some script may contain
358
357
` npx commitlint ` and here Knip assumes ` commitlint ` is the name of the package.
359
358
This technically works, as ` commitlint ` is a transitive dependency of
360
- ` @commitlint/cli ` . However, correct and recommeded usage is by the package name:
361
- ` npx @commitlint/cli ` .
359
+ ` @commitlint/cli ` .
360
+
361
+ ** Solution** : use ` npx @commitlint/cli `
362
+
363
+ In some cases, using ` npx ` in a script may result in Knip not understanding
364
+ intention without an explicit ` --yes ` or ` --no-install ` flag.
365
+
366
+ ** Solution** : use ` npx --yes ` or ` npx --no-install ` so Knip will either ignore
367
+ or consider the binary and package(s) referenced, respectively.
362
368
363
369
## Unresolved imports
364
370
0 commit comments