Skip to main content

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:

  1. You haven't called wireCLI() to register any CLI programs
  2. The Pikku CLI build step (npx pikku all or yarn pikku) hasn't been run
  3. 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 all after adding CLI wirings
  • Not importing the generated bootstrap file
  • Typo in the program name between wireCLI() and executeCLI()
  • The CLI file isn't in a directory listed in srcDirectories in pikku.config.json
  • PKU370 - CLI command not found