Troubleshooting
This guide helps you resolve common issues when using the CLI template.
Common Issues
Build Errors
TypeScript Compilation Errors
If you encounter TypeScript compilation errors:
- Check your
tsconfig.json
settings - Ensure all dependencies are installed:bash
pnpm install
- Clear the build cache:bash
rm -rf dist pnpm build
Module Resolution Errors
If you see module resolution errors:
- Check your import paths are correct
- Verify the
@
alias is properly configured intsconfig.json
- Ensure all dependencies are listed in
package.json
Test Failures
Test Environment Issues
If tests are failing:
- Check your
vitest.config.ts
settings - Ensure test files are in the correct location
- Run tests with debug mode:bash
DEBUG=true pnpm test
Mocking Issues
If mocks aren't working:
- Verify mock implementations
- Check for proper cleanup in
afterEach
- Ensure mocks are properly typed
Runtime Errors
Command Not Found
If commands aren't being recognized:
- Check your
package.json
bin configuration - Verify the command is properly exported
- Try reinstalling the CLI:bash
pnpm unlink --global pnpm link --global
Permission Issues
If you encounter permission errors:
- Check file permissions
- Run with appropriate user permissions
- Use
sudo
if necessary (not recommended for development)
Debug Mode
Enable debug mode to get more detailed information:
bash
# Set debug environment variable
DEBUG=true cli-template interactive
# Or use the debug flag
cli-template interactive --debug
Debug output includes:
- Command execution flow
- Configuration loading
- Error stack traces
- Performance metrics
Error Messages
Common Error Types
Configuration Errors
Error: Invalid configuration file
- Check your configuration files
- Verify environment variables
Validation Errors
Error: Invalid input provided
- Check input format
- Verify required fields
Runtime Errors
Error: Operation failed
- Check system resources
- Verify dependencies
Error Handling
The template includes built-in error handling:
typescript
try {
await operation();
} catch (error) {
if (error instanceof CLIError) {
logger.error(`CLI Error: ${error.message}`);
} else {
logger.error('An unexpected error occurred:', error);
}
process.exit(1);
}
Getting Help
Documentation
- Check the documentation for detailed guides
- Read API reference for function documentation
Community Support
- Open an issue on GitHub
- Check existing issues for solutions
- Join the community discussions
Next Steps
- Configuration - Learn about CLI configuration
- Testing - Set up your test suite
- Best Practices - Tips for CLI development