Registry / devops / rollup-plugin-preserve-shebang

rollup-plugin-preserve-shebang

JSON →
library1.0.1jsnpmunverified

A Rollup plugin that automatically preserves a shebang (#!) line from your entry file in the bundle output. Version 1.0.1 is current stable, with maintenance-level activity. Key differentiator: it handles multi-entry setups and allows overriding the shebang string, unlike alternatives that only work with single entries or require manual configuration. It auto-detects the shebang from the entry file or can be explicitly set via plugin options. Supports Rollup 1+ and Node 14+. Lightweight with no dependencies.

npm install rollup-plugin-preserve-shebang
INSTALL
IMPORT
SIG · ROLLUP-PLUGIN-PRES
R
rollup-plugin-preserve-shebang
devopsjavascriptv1.0.1
Install
—
Import
—
Disk
—
Pass rate
0/ 6
Env Coverage0 / 6
glibc
18–22
musl
18–22
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 18–223 runs
build_error
glibc
node 18–223 runs
build_error
Code
Verified usage

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

default
✓ import shebang from 'rollup-plugin-preserve-shebang'
✗ const shebang = require('rollup-plugin-preserve-shebang')
Package is ESM-only; CommonJS require will fail with ERR_REQUIRE_ESM.
default (named import)
✓ import shebang from 'rollup-plugin-preserve-shebang'
✗ import { shebang } from 'rollup-plugin-preserve-shebang'
Only default export exists; named import will not work.
plugin usage in Rollup config
✓ export default { plugins: [shebang()] }
✗ export default { plugins: [shebang] }
shebang must be called as a function; passing the function reference directly will cause error.

Shows basic usage: import the default export, call shebang() in Rollup's plugins array to preserve the shebang from the entry file.

import shebang from 'rollup-plugin-preserve-shebang'; export default { input: 'src/cli.js', output: { file: 'dist/cli.js', format: 'cjs' }, plugins: [ shebang() ] };
Debug
Known issues
gotchaThe plugin only works with Rollup 1+; older versions are incompatible.
fix
Upgrade Rollup to version 1 or higher.
affects: <1.0.0
gotchaIf the entry file has no shebang, the plugin does nothing—it does not add one unless explicitly set via the `shebang` option.
fix
Either ensure the entry file starts with #! or use the `shebang` option to provide one.
affects: >=0.0.0
gotchaThe package is ESM-only and cannot be required via CommonJS require.
fix
Use dynamic import() or ensure your project uses ESM (type: 'module' in package.json).
affects: >=1.0.0
Errors
Common errors & fixes
Error [ERR_REQUIRE_ESM]: require() of ES Module /path/to/node_modules/rollup-plugin-preserve-shebang/src/index.js from /path/to/rollup.config.js not supported.
CommonJS require used with an ESM-only package.
fix
Use import syntax instead of require, or convert your config to ESM by adding 'type': 'module' in package.json.
TypeError: shebang is not a function
shebang import is the function itself, but it was not called (e.g., used shebang instead of shebang() in plugins array).
fix
Call shebang() function: plugins: [shebang()].
Error: No shebang found in entry file 'cli.js'
Entry file does not start with #!, and no explicit shebang option was provided.
fix
Add #!/usr/bin/env node as first line of entry file, or provide shebang option: shebang({ shebang: '#!/usr/bin/env node' }).
Upgrade
Version history
1.0.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
2 hits · last 30 days
node
2
Resources
rollup-plugin-preserve-shebang — npm install rollup-plugin-preserve-shebang · libregistry