Registry / devops / rollup-plugin-cli

rollup-plugin-cli

JSON →
library0.1.5jsnpmunverified

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.

npm install rollup-plugin-cli
INSTALL
IMPORT
SIG · ROLLUP-PLUGIN-CLI
R
rollup-plugin-cli
devopsjavascriptv0.1.5
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18223 runs
build_error
glibc
node 18223 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
import cli from 'rollup-plugin-cli'
const cli = require('rollup-plugin-cli')
ESM-only; no CommonJS support. Use import syntax.
plugin function
plugins: [ cli() ]
plugins: [ cli ]
Must be called as a function (with or without options) in the plugins array.
TypeScript import
import cli from 'rollup-plugin-cli'
import * as cli from 'rollup-plugin-cli'
The plugin has no type definitions; use with @rollup/plugin-typescript or similar.

Minimal Rollup configuration that adds a Node.js hashbang to the output bundle.

// rollup.config.js import cli from 'rollup-plugin-cli'; export default { input: 'src/index.js', output: { file: 'bin/cli.js', format: 'cjs' }, plugins: [ cli() // adds #!/usr/bin/env node ] };
Debug
Known issues
gotchaThe 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.
fix
Ensure your CLI script is the first entry point or combine outputs manually.
affects: >=0.0.0
gotchaThe 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.
fix
After bundling, run chmod +x on the output file.
affects: >=0.0.0
gotchaThe plugin does not handle Windows line endings or carriage returns. On Windows, the hashbang may not work as expected.
fix
Use a cross-platform tool like 'pkg' or include a post-build step to adjust line endings.
affects: >=0.0.0
Errors
Common errors & fixes
Error: Cannot find module 'rollup-plugin-cli'
The package is not installed or the import path is incorrect (e.g., missing file extension).
fix
Run 'npm install rollup-plugin-cli' and use 'import cli from 'rollup-plugin-cli'' (no extension).
TypeError: cli is not a function
Forgetting to call the exported function in the plugins array.
fix
Use 'cli()' with parentheses, e.g., 'plugins: [ cli() ]'.
Hashbang added to wrong output
When using multiple output formats or code splitting, the hashbang is only added to the first output chunk.
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.
Upgrade
Version history
0.1.5latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
9 hits · last 30 days
node
8
Resources
rollup-plugin-cli — npm install rollup-plugin-cli · libregistry