Skip to main content

package.json bin Builder

v1.0.0

Generate the bin field with conflict checks — single string or map form, shebang reminder.

package.json bin section
// package.json excerpt:
{
  "name": "my-cli",
  "bin": "./bin/cli.js",
  "files": ["bin/", "dist/"]
}

// ./bin/cli.js
#!/usr/bin/env node
// or for ESM:
#!/usr/bin/env -S node --input-type=module

import { run } from "../dist/index.js";
run();

// Make executable:
chmod +x ./bin/cli.js

// Test locally:
npm link   # then run: my-cli