Troubleshooting
This section helps you diagnose and resolve common issues when working with Watt and Platformatic applications.
Common Issues and Solutions
Installation and Setup Issues
"Command not found: wattpm"
Problem: After installing wattpm, the command is not recognized.
Solution:
# If installed globally, ensure npm global bin is in your PATH
npm list -g --depth=0
npm config get prefix
# If the prefix is not in your PATH, add it:
echo 'export PATH="$(npm config get prefix)/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc
# Alternatively, install locally and use npx:
npm install wattpm
npx wattpm --help
Configuration File Not Found
Problem: Error: "No config file found" or "Cannot parse config file"
Solution:
-
Ensure you have a configuration file in the current directory:
watt.json(recommended for Watt applications)
-
Check file format and syntax:
# Validate JSON syntax
cat watt.json | jq . -
Use the
--configoption to specify a custom path:wattpm start --config ./config/my-watt.json
Database Connection Issues
Database Connection Failed
Problem: "Connection refused" or "Authentication failed" errors.
Solution:
-
Check connection string format:
// PostgreSQL
'postgres://username:password@host:port/database'
// MySQL
'mysql://username:password@host:port/database'
// SQLite
'sqlite://./path/to/database.sqlite' -
Test database connectivity:
# PostgreSQL
psql "postgres://user:pass@host:port/db" -c "SELECT 1;"
# MySQL
mysql -h host -P port -u user -p database -e "SELECT 1;" -
Use environment variables for credentials:
{
"db": {
"connectionString": "{PLT_DATABASE_URL}"
}
}export PLT_DATABASE_URL="postgres://user:pass@localhost:5432/mydb"
Migrations Not Applied
Problem: "You have migrations to apply" error.
Solution:
# Apply pending migrations
wattpm db:migrations:apply
K```
### Application Discovery and Communication Issues
#### Application Not Found
**Problem:** "Application not found" or "Application with id 'X' is not started" errors.
**Solution:**
1. **Check running applications:**
```bash
wattpm ps
wattpm applications
-
Verify application configuration:
wattpm config -
Check application health:
wattpm inject --path /health
wattpm logs application-name
Port Already in Use
Problem: "EADDRINUSE: address already in use" error.
Solution:
# Find process using the port
lsof -i :3042
# or
netstat -tulpn | grep 3042
# Kill the process (replace PID with actual process ID)
kill -9 PID
# Or change the port in configuration
Development and Hot Reload Issues
Changes Not Reflected
Problem: Code changes don't appear when running wattpm dev.
Solution:
-
Check watch configuration:
{
"watch": {
"enabled": true,
"path": "./src",
"ignore": ["*.test.js", "node_modules"]
}
} -
Restart development server:
# Stop current process (Ctrl+C)
wattpm dev -
Check file permissions and symlinks:
ls -la ./src
TypeScript Issues
TypeScript Compilation Errors
Problem: "Cannot find module" or TypeScript compilation errors.
Solution:
# Compile TypeScript plugins
wattpm build
# Generate TypeScript types
wattpm db:types
# Check TypeScript configuration
cat tsconfig.json
Production Deployment Issues
Build Failures
Problem: Application fails to build for production.
Solution:
-
Check dependencies:
wattpm install --production -
Compile all applications:
wattpm build -
Check for missing environment variables:
wattpm env
Performance Issues
Problem: Slow response times or high memory usage in production.
Solution:
-
Enable metrics collection:
{
"metrics": {
"enabled": true,
"endpoint": "/metrics"
}
} -
Check logs for errors:
wattpm logs --level error -
Monitor resource usage:
wattpm inject --path /metrics
Error Reference
Configuration Errors
| Error Code | Description | Solution |
|---|---|---|
| PLT_CONFIG_NO_CONFIG_FILE_FOUND | Configuration file not found | Create a watt.json or use --config option |
| PLT_CONFIG_CANNOT_PARSE_CONFIG_FILE | Invalid configuration file syntax | Validate JSON/YAML syntax |
| PLT_CONFIG_VALIDATION_ERRORS | Configuration doesn't match schema | Check configuration against schema |
| PLT_CONFIG_ENV_VAR_MISSING | Environment variable not set | Set required environment variables |
Database Errors
| Error Code | Description | Solution |
|---|---|---|
| PLT_SQL_MAPPER_CONNECTION_STRING_REQUIRED | Missing database connection | Add connectionString to config |
| PLT_DB_MIGRATIONS_TO_APPLY_ERROR | Pending migrations | Run wattpm db:migrations:apply |
| PLT_DB_UNKNOWN_DATABASE_ERROR | Unsupported database | Use PostgreSQL, MySQL, MariaDB, or SQLite |
Runtime Errors
| Error Code | Description | Solution |
|---|---|---|
| PLT_RUNTIME_EADDR_IN_USE | Port already in use | Change port or kill existing process |
| PLT_RUNTIME_APPLICATION_NOT_FOUND | Application not found | Check application ID and configuration |
| PLT_RUNTIME_APPLICATION_NOT_STARTED | Application not running | Start application with wattpm start |
For a complete list of error codes, see the Error Reference.