paperclipai/paperclip · error · Error
usage: prepare-npm-readme.mjs
Error message
usage: prepare-npm-readme.mjs <source> <destination> <asset-ref>
What it means
When prepare-npm-readme.mjs is executed directly (process.argv[1] resolves to the module file), it expects exactly three CLI arguments: source README path, destination path, and the immutable asset ref. Missing any of them aborts with the usage line, since it cannot guess where to read, write, or which ref to pin.
Solutions
- Run with all three arguments: node scripts/prepare-npm-readme.mjs <source> <destination> <asset-ref>.
- If the ref comes from an env var or command substitution, echo it first to confirm it is non-empty before invoking.
- Quote each path argument in the shell so spaces or empty variables do not collapse positional arguments.
Example fix
// before (shell) node scripts/prepare-npm-readme.mjs README.md dist/README.md $REF // after REF=$(git rev-parse HEAD); node scripts/prepare-npm-readme.mjs README.md dist/README.md "$REF"
Defensive patterns
Strategy: validation
Validate before calling
const [sourcePath, destinationPath, assetRef] = process.argv.slice(2);
if (!sourcePath || !destinationPath || !assetRef) {
console.error('usage: prepare-npm-readme.mjs <source> <destination> <asset-ref>');
process.exit(1);
} Try / catch
try { main(); } catch (e) { if (e.message.startsWith('usage: prepare-npm-readme')) { console.error(e.message); process.exit(1); } throw e; } Prevention
- Quote all path arguments and verify env-derived refs are non-empty before invoking.
- Check the script's usage line with --help-style invocation when unsure of argument order.
- In CI, add a pre-step echoing all three resolved arguments before running the script.
When it happens
Trigger: Running `node scripts/prepare-npm-readme.mjs` or with fewer than three space-separated arguments; quoting mistakes that collapse arguments (e.g. passing "README.md dist/" as one token); calling the script from a wrapper that drops the asset-ref argument.
Common situations: Copy-pasting the command from docs but omitting the ref; shell variable expansions resolving to empty strings (e.g. $COMMIT_SHA unset); CI steps edited to remove what looked like a redundant argument.
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
- Expected plan, plan-migrator, pack, publish, publish-image…
- is required
- Missing
- Worktree seed source is not registered. Managed boot…
- A safe, unique --revision is required
AI-assisted analysis of paperclipai/paperclip@3f1d897a7c (2026-09-18).
Data as JSON: /api/errors/0d439c0041d07bfb.
Report an issue: GitHub.
Appendix: source
Thrown at scripts/prepare-npm-readme.mjs:29
`https://raw.githubusercontent.com/paperclipai/paperclip/${assetRef}/doc/assets/`;
return readme.replace(
/((?:src|srcset)=["'])([^"']*)(["'])/g,
(_match, prefix, value, suffix) =>
`${prefix}${value.replace(
/(^|,\s*)doc\/assets\//g,
`$1${assetBaseUrl}`,
)}${suffix}`,
);
}
const isDirectRun =
process.argv[1] && path.resolve(process.argv[1]) === fileURLToPath(import.meta.url);
if (isDirectRun) {
const [sourcePath, destinationPath, assetRef] = process.argv.slice(2);
if (!sourcePath || !destinationPath || !assetRef) {
throw new Error(
"usage: prepare-npm-readme.mjs <source> <destination> <asset-ref>",
);
}
writeFileSync(
destinationPath,
prepareNpmReadme(readFileSync(sourcePath, "utf8"), assetRef),
);
}
View on GitHub (pinned to 3f1d897a7c)