JuliusBrussee/caveman · error · Error
usage: npm create @caveman-ai/agent@latest
Error message
usage: npm create @caveman-ai/agent@latest <project> [--provider anthropic|openai|google] [--no-install]
What it means
After flag parsing, exactly one positional argument (the target project name/directory) is required. Zero positionals or more than one cause parseArgs to throw the full usage string so the developer sees the correct command shape.
Solutions
- Supply exactly one project name: `npm create @caveman-ai/agent@latest my-app`
- Quote paths containing spaces: `"my app"`
- Remove extra positional words; flags like --provider already carry their own values
Example fix
// before npm create @caveman-ai/agent@latest // after npm create @caveman-ai/agent@latest my-app -- --provider anthropic
Defensive patterns
Strategy: validation
Validate before calling
const positional = argv.filter(a => !a.startsWith("--"));
if (positional.length !== 1) throw new Error(USAGE); Type guard
function hasSinglePositional(argv: string[]): boolean {
return argv.filter(a => !a.startsWith("--")).length === 1;
} Try / catch
try {
const opts = parseArgs(argv);
} catch (error) {
if (error instanceof Error && error.message.startsWith("usage:")) {
console.error(error.message);
process.exitCode = 1;
} else throw error;
} Prevention
- Always pass exactly one project name positional
- Quote project paths containing spaces
- Remember flags consume their own values and don't count as positionals
When it happens
Trigger: Running the create command with no project name (`npm create @caveman-ai/agent@latest -- --provider openai`), or with two or more positional names, or a quoted path that the shell splits into multiple tokens.
Common situations: Forgetting the project argument entirely; paths with unquoted spaces (`my app` becomes two positionals — quote it); passing a description sentence as extra words.
Understand the failure class
Background: "no subcommand specified" and "... is required": CLI errors when a required argument is missing — this error's family across 13 libraries.
Related errors
AI-assisted analysis of JuliusBrussee/caveman@3ee70a1026 (2026-09-20).
Data as JSON: /api/errors/5fc30a1232b4514a.
Report an issue: GitHub.
Appendix: source
Thrown at packages/create-caveman-agent/src/index.ts:79
let install = true;
const positional: string[] = [];
for (let index = 0; index < args.length; index++) {
const value = args[index]!;
if (value === "--provider") {
const candidate = args[++index];
if (!candidate || candidate.startsWith("--")) throw new Error("--provider requires a value");
provider = candidate;
continue;
}
if (value === "--no-install") {
install = false;
continue;
}
if (value.startsWith("--")) throw new Error(`unknown option ${value}`);
positional.push(value);
}
if (positional.length !== 1) {
throw new Error(
USAGE,
);
}
return {
target: positional[0]!,
...(provider === undefined ? {} : { provider }),
install,
};
}
async function installDependencies(directory: string): Promise<void> {
const npmExecPath = process.env.npm_execpath;
const windowsShell = !npmExecPath && process.platform === "win32";
const command = npmExecPath
? process.execPath
: windowsShell
? process.env.ComSpec ?? "cmd.exe"
: "npm";View on GitHub (pinned to 3ee70a1026)