{"id":21952,"library":"rollup-plugin-cli","title":"Rollup Plugin CLI","description":"A rollup plugin that prepends a hashbang (shebang) line to bundled JavaScript files for CLI use. The current stable version is 0.1.5. The plugin is minimalist and has no notable release cadence. It differentiates itself by being a straightforward, small plugin that simply adds a hashbang to the output bundle, allowing Rollup to generate executable CLI scripts. It supports a configurable hashbang via options and has no dependencies. It is only useful for Node.js CLI projects built with Rollup and should not be used for browser bundles.","status":"active","version":"0.1.5","language":"javascript","source_language":"en","source_url":"ssh://git@github.com/tkuminecz/rollup-plugin-cli","tags":["javascript","rollup","plugin","cli","bin"],"install":[{"cmd":"npm install rollup-plugin-cli","lang":"bash","label":"npm"},{"cmd":"yarn add rollup-plugin-cli","lang":"bash","label":"yarn"},{"cmd":"pnpm add rollup-plugin-cli","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"ESM-only; no CommonJS support. Use import syntax.","wrong":"const cli = require('rollup-plugin-cli')","symbol":"default","correct":"import cli from 'rollup-plugin-cli'"},{"note":"Must be called as a function (with or without options) in the plugins array.","wrong":"plugins: [ cli ]","symbol":"plugin function","correct":"plugins: [ cli() ]"},{"note":"The plugin has no type definitions; use with @rollup/plugin-typescript or similar.","wrong":"import * as cli from 'rollup-plugin-cli'","symbol":"TypeScript import","correct":"import cli from 'rollup-plugin-cli'"}],"quickstart":{"code":"// rollup.config.js\nimport cli from 'rollup-plugin-cli';\n\nexport default {\n  input: 'src/index.js',\n  output: {\n    file: 'bin/cli.js',\n    format: 'cjs'\n  },\n  plugins: [\n    cli() // adds #!/usr/bin/env node\n  ]\n};","lang":"javascript","description":"Minimal Rollup configuration that adds a Node.js hashbang to the output bundle."},"warnings":[{"fix":"Ensure your CLI script is the first entry point or combine outputs manually.","message":"The plugin only prepends the hashbang to the first output chunk. If using code-splitting or multiple outputs, only the first entry point chunk gets the hashbang.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"After bundling, run chmod +x on the output file.","message":"The hashbang line is added as text; there is no validation the resulting file will be executable. You must still set executable permissions (chmod +x) on the output file.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Use a cross-platform tool like 'pkg' or include a post-build step to adjust line endings.","message":"The plugin does not handle Windows line endings or carriage returns. On Windows, the hashbang may not work as expected.","severity":"gotcha","affected_versions":">=0.0.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Run 'npm install rollup-plugin-cli' and use 'import cli from 'rollup-plugin-cli'' (no extension).","cause":"The package is not installed or the import path is incorrect (e.g., missing file extension).","error":"Error: Cannot find module 'rollup-plugin-cli'"},{"fix":"Use 'cli()' with parentheses, e.g., 'plugins: [ cli() ]'.","cause":"Forgetting to call the exported function in the plugins array.","error":"TypeError: cli is not a function"},{"fix":"Structure your Rollup config so that the CLI entry point is the sole input or use a different plugin to add hashbangs per chunk.","cause":"When using multiple output formats or code splitting, the hashbang is only added to the first output chunk.","error":"Hashbang added to wrong output"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}