rollup-plugin-bin

raw JSON →
1.0.0 verified Mon Apr 27 auth: no javascript maintenance

Rollup plugin that prepends an executable shebang (#!/usr/bin/env node) to the output bundle, enabling CLI scripts. Version 1.0.0, stable but minimal, with no releases since 2020. Differentiators: lightweight, no dependencies, works with any output format. Not actively maintained; alternatives include @rollup/plugin-banner or manual banner injection.

error TypeError: bin is not a function
cause Named import (import { bin } from 'rollup-plugin-bin') instead of default import.
fix
Use import bin from 'rollup-plugin-bin' or const bin = require('rollup-plugin-bin').default.
error Error: Cannot find module 'rollup-plugin-bin'
cause Package not installed or improper import path.
fix
Run npm install rollup-plugin-bin --save-dev and ensure correct require/import.
gotcha Plugin only prepends shebang; does not set executable permission on output file.
fix Use chmod +x after build, or configure output.permissions in rollup.
gotcha No support for custom shebang strings other than default #!/usr/bin/env node.
fix Use @rollup/plugin-banner with custom shebang or fork plugin.
breaking Deprecated: Plugin is not actively maintained; may break with future rollup versions.
fix Consider migrating to @rollup/plugin-banner or include banner manually via output.banner.
npm install rollup-plugin-bin
yarn add rollup-plugin-bin
pnpm add rollup-plugin-bin

Basic rollup config adding shebang to a CLI output file using rollup-plugin-bin.

import bin from 'rollup-plugin-bin';

export default {
  input: 'src/index.ts',
  output: { file: 'bin/cli.js', format: 'cjs' },
  plugins: [bin()]
};