Troubleshooting#
Panduan troubleshooting untuk masalah umum di Lokio CLI.
Common Issues#
1. "lokio.yaml not found"#
Error:
lokio.yaml not found. Run 'lokio init' first.
Solution:
lokio initCause:
- Project belum di-initialize
- Berada di directory yang salah
2. "configs.yaml not found"#
Error:
configs.yaml not found. Run 'lokio init' first.
Solution:
lokio initCause:
- File
lokio/configs.yamltidak ada - Folder
lokio/tidak ada
3. "Template file not found"#
Error:
Template file not found: example.lokio
Solution:
- Check file ada di
lokio/templates/example.lokio - Check path di
configs.yamlbenar:path: "example.lokio" # Relatif ke lokio/templates/ - Check file name match dengan path di config
Common Mistakes:
- Path include
templates/prefix → seharusnya hanya nama file - File name typo
- File di folder yang salah
4. "Invalid configs.yaml format"#
Error:
Invalid configs.yaml format.
Solution:
- Check YAML syntax
- Check required fields ada:
namedescriptionpathoutputparameters(array)
- Validate YAML dengan online validator
Common Mistakes:
- Missing required fields
- Wrong indentation
- Invalid YAML syntax
- Missing quotes untuk strings dengan special chars
5. "Template name already exists"#
Error:
Template name already exists
Solution:
- Gunakan nama template yang berbeda
- Atau hapus template lama dulu:
lokio template remove <old-name>
6. Parameter tidak muncul saat generate#
Symptoms:
- Parameter yang ditambah di
configs.yamltidak muncul sebagai prompt
Solution:
- Check parameter ada di
configs.yaml:parameters: - name: "myParam" type: "string" required: true prompt: "My parameter" - Check YAML syntax benar
- Check parameter format benar (name, type, required, prompt)
- Restart generate command
Common Mistakes:
- Parameter tidak di array
parameters: - Missing required fields
- Wrong indentation
7. Case transformation tidak bekerja#
Symptoms:
<%= Name %>tidak menjadi Capitalize- Helper functions tidak bekerja
Solution:
- Check variable name:
<%= Name %>(huruf besar pertama) - Check helper function:
<%= capitalize(name) %> - Check input adalah string (bukan number/boolean)
Common Mistakes:
- Variable name typo
- Helper function typo
- Input bukan string
8. Output path tidak benar#
Symptoms:
- File di-generate ke path yang salah
- Path tidak menggunakan parameters
Solution:
- Check output path di
configs.yaml:output: "src/components/<%= name %>.tsx" - Check EJS syntax benar
- Check parameters ada dan benar
Common Mistakes:
- EJS syntax salah:
{{ name }}→ seharusnya<%= name %> - Parameter name typo
- Path tidak menggunakan EJS
9. File sudah ada, tidak ditanya overwrite#
Symptoms:
- File di-generate tanpa konfirmasi overwrite
Solution:
- Ini seharusnya tidak terjadi, file yang sudah ada harus ditanya
- Check apakah file benar-benar ada
- Check permissions
10. Template tidak muncul di list#
Symptoms:
- Template yang ditambah tidak muncul di
lokio list
Solution:
- Check template ada di
configs.yaml - Check YAML syntax benar
- Check template name unique
- Run
lokio listuntuk lihat error
Common Mistakes:
- Template tidak di array
templates: - YAML syntax error
- Missing required fields
YAML Syntax Issues#
Wrong Indentation#
Wrong:
templates:
- name: "example" # Missing indentationCorrect:
templates:
- name: "example" # Correct indentationMissing Quotes#
Wrong:
name: example component # Space needs quotesCorrect:
name: "example component"Array Syntax#
Wrong:
parameters: name, type # Not arrayCorrect:
parameters:
- name: "name"
type: "string"EJS Syntax Issues#
Wrong EJS Tags#
Wrong:
{{ name }} # Handlebars syntax
${name} # Template literalCorrect:
<%= name %> # EJS output
<% code %> # EJS codeUnclosed Tags#
Wrong:
<% if (condition) { %>
// Missing closing tagCorrect:
<% if (condition) { %>
// Content
<% } %>File Path Issues#
Absolute vs Relative#
Wrong:
path: "/templates/example.lokio" # Absolute
path: "templates/example.lokio" # Wrong prefixCorrect:
path: "example.lokio" # Relative to lokio/templates/
path: "components/example.lokio" # With subfolderOutput Path#
Wrong:
output: "components/<%= name %>.tsx" # No src/ prefixCorrect:
output: "src/components/<%= name %>.tsx"Debugging Tips#
1. Check Files#
# Check lokio.yaml exists
cat lokio.yaml
# Check configs.yaml
cat lokio/configs.yaml
# Check template file
cat lokio/templates/example.lokio2. Validate YAML#
# Online validator
# https://www.yamllint.com/
# Or use yq (if installed)
yq eval lokio/configs.yaml3. Test Template#
# Generate dengan verbose
lokio generate
# Check output
ls -la src/components/4. Check Parameters#
# List templates dengan detail
lokio list
# Check parameters di configs.yaml
cat lokio/configs.yaml | grep -A 10 parametersGetting Help#
Jika masih ada masalah:
-
Check Documentation
-
Check Examples
-
Validate Config
- Check YAML syntax
- Check required fields
- Check file paths
-
Test Simple Case
- Start dengan template sederhana
- Test dengan 1 parameter
- Gradually add complexity
Error Messages Reference#
| Error | Cause | Solution |
|---|---|---|
lokio.yaml not found | Not initialized | Run lokio init |
configs.yaml not found | Not initialized | Run lokio init |
Template file not found | File missing/wrong path | Check file exists, check path |
Invalid configs.yaml format | YAML syntax error | Fix YAML syntax |
Template name already exists | Duplicate name | Use different name |
Missing required parameters | Parameter not provided | Provide all required params |
Failed to render template | EJS syntax error | Fix EJS syntax |
Failed to render output path | EJS syntax error in path | Fix output path EJS |
Prevention#
Untuk menghindari masalah:
- ✅ Always validate - Check YAML syntax sebelum save
- ✅ Use examples - Start dari contoh yang bekerja
- ✅ Test incrementally - Tambah complexity gradually
- ✅ Check paths - Pastikan file paths benar
- ✅ Use descriptive names - Avoid typos dengan clear names