PKU342: CLI Metadata Not Found
Error Message
CLI metadata not found. No CLI wirings were registered.
What Went Wrong
You're trying to execute a CLI program, but Pikku hasn't found any CLI wirings in your application. This happens when:
- You haven't called
wireCLI()to register any CLI programs - The Pikku CLI build step (
npx pikku alloryarn pikku) hasn't been run - The generated bootstrap file isn't being imported properly
How to Fix
Step 1: Define a CLI Program
Create a CLI wiring using wireCLI():
// src/cli.ts
import { wireCLI } from '@pikku/core/cli'
import { pikkuFunc } from '#pikku'
wireCLI({
program: 'my-cli',
commands: {
hello: pikkuFunc(async () => {
console.log('Hello, world!')
})
}
})
Step 2: Configure CLI Generation
Add CLI configuration to your pikku.config.json:
{
"tsconfig": "./tsconfig.json",
"srcDirectories": ["src"],
"outDir": ".pikku",
"cli": {
"entrypoints": {
"my-cli": ".pikku/cli/my-cli.gen.ts"
}
}
}
Step 3: Run the Build
Generate the CLI bootstrap files:
npx pikku all
# or
yarn pikku
Step 4: Import the Bootstrap
Make sure your entry point imports the generated bootstrap:
// src/index.ts or bin/my-cli.ts
import './.pikku/pikku-bootstrap.gen.js'
import { executeCLI } from '@pikku/core/cli'
executeCLI({
programName: 'my-cli',
args: process.argv.slice(2),
createSingletonServices: async () => ({
// your services
})
})
Common Mistakes
- Forgetting to run
npx pikku allafter adding CLI wirings - Not importing the generated bootstrap file
- Typo in the program name between
wireCLI()andexecuteCLI() - The CLI file isn't in a directory listed in
srcDirectoriesinpikku.config.json
Related Documentation
- CLI Guide - Complete CLI setup guide
- Pikku CLI Tool - Using the Pikku CLI generator
Related Errors
- PKU370 - CLI command not found