Date: 2025-07-06
Purpose: Verify that all Commander.js CLIs properly report their package.json version
Checked 10 projects in ~/code that use Commander.js. All projects successfully built, but one project (fs-to-xml) has a runtime dependency issue.
- ✅ 9 of 10 projects have matching CLI and package.json versions
⚠️ 1 of 10 projects has a missing dependency preventing version check⚠️ 7 of 9 working projects incorrectly output "Error:" with their version- ✅ 2 of 9 working projects (context-composer-cli, tmux-composer-cli) have clean version output
| Project | Package Version | CLI Version | Status | Notes |
|---|---|---|---|---|
| fs-to-xml | 0.1.0 | ❌ Error | Missing 'bash-parser' dependency | |
| theme-installer-cli | 0.1.1 | 0.1.1 | ✅ Match | |
| meta-composer-cli | 0.1.0 | 0.1.0 | ✅ Match | |
| context-composer-cli | 0.1.0 | 0.1.0 | ✅ Match | ✅ Clean output |
| commanderjs-template | 0.1.0 | 0.1.0 | ✅ Match | |
| claude-code-generic-hooks | 0.1.4 | 0.1.4 | ✅ Match | |
| claude-code-inject | 0.1.7 | 0.1.7 | ✅ Match | |
| claude-code-chat-stream | 0.1.3 | 0.1.3 | ✅ Match | |
| tmux-composer-cli | 0.1.1 | 0.1.1 | ✅ Match | ✅ Clean output |
| comment-destroyer | 0.1.0 | 0.1.0 | ✅ Match |
Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'bash-parser' imported from /home/mike/code/fs-to-xml/dist/cli.js
- The project builds successfully but fails at runtime
- Missing 'bash-parser' dependency prevents version check
- Recommendation: Add 'bash-parser' to package.json dependencies
Most projects (7 out of 9 working ones) incorrectly display "Error: " when running --version. This happens because:
- These projects use
program.exitOverride()in their Commander.js setup - When
--versionis called, Commander throws an error with codecommander.version - The error handling code doesn't check for this specific error code
- The version number gets printed as an error message
- theme-installer-cli
- meta-composer-cli
- commanderjs-template
- claude-code-generic-hooks
- claude-code-inject
- claude-code-chat-stream
- comment-destroyer
- context-composer-cli ✅
- tmux-composer-cli ✅
Add a check for commander.version in the error handling:
if (
error.code === 'commander.help' ||
error.code === 'commander.helpDisplayed' ||
error.code === 'commander.version'
) {
process.exit(0)
}All projects share these traits:
- Use Commander.js
^12.0.0 - Built with
tsup - TypeScript-based
- ES modules (
"type": "module") - Require Node.js 18+
- All have executable at
./dist/cli.js
While all functional projects correctly report their version numbers, most have a cosmetic issue where the version is incorrectly prefixed with "Error:". This is due to incomplete error handling when using exitOverride() with Commander.js.
- Fix fs-to-xml by adding the missing 'bash-parser' dependency
- Update error handling in 7 projects to properly handle the
commander.versionerror code - Use context-composer-cli or tmux-composer-cli as reference implementations for clean version output