{"id":22179,"library":"rollup-plugin-preserve-shebang","title":"rollup-plugin-preserve-shebang","description":"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.","status":"active","version":"1.0.1","language":"javascript","source_language":"en","source_url":"https://github.com/developit/rollup-plugin-preserve-shebang","tags":["javascript","rollup","plugin","shebang","hashbang"],"install":[{"cmd":"npm install rollup-plugin-preserve-shebang","lang":"bash","label":"npm"},{"cmd":"yarn add rollup-plugin-preserve-shebang","lang":"bash","label":"yarn"},{"cmd":"pnpm add rollup-plugin-preserve-shebang","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Package is ESM-only; CommonJS require will fail with ERR_REQUIRE_ESM.","wrong":"const shebang = require('rollup-plugin-preserve-shebang')","symbol":"default","correct":"import shebang from 'rollup-plugin-preserve-shebang'"},{"note":"Only default export exists; named import will not work.","wrong":"import { shebang } from 'rollup-plugin-preserve-shebang'","symbol":"default (named import)","correct":"import shebang from 'rollup-plugin-preserve-shebang'"},{"note":"shebang must be called as a function; passing the function reference directly will cause error.","wrong":"export default { plugins: [shebang] }","symbol":"plugin usage in Rollup config","correct":"export default { plugins: [shebang()] }"}],"quickstart":{"code":"import shebang from 'rollup-plugin-preserve-shebang';\n\nexport default {\n  input: 'src/cli.js',\n  output: {\n    file: 'dist/cli.js',\n    format: 'cjs'\n  },\n  plugins: [\n    shebang()\n  ]\n};","lang":"javascript","description":"Shows basic usage: import the default export, call shebang() in Rollup's plugins array to preserve the shebang from the entry file."},"warnings":[{"fix":"Upgrade Rollup to version 1 or higher.","message":"The plugin only works with Rollup 1+; older versions are incompatible.","severity":"gotcha","affected_versions":"<1.0.0"},{"fix":"Either ensure the entry file starts with #! or use the `shebang` option to provide one.","message":"If the entry file has no shebang, the plugin does nothing—it does not add one unless explicitly set via the `shebang` option.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Use dynamic import() or ensure your project uses ESM (type: 'module' in package.json).","message":"The package is ESM-only and cannot be required via CommonJS require.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Use import syntax instead of require, or convert your config to ESM by adding 'type': 'module' in package.json.","cause":"CommonJS require used with an ESM-only package.","error":"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."},{"fix":"Call shebang() function: plugins: [shebang()].","cause":"shebang import is the function itself, but it was not called (e.g., used shebang instead of shebang() in plugins array).","error":"TypeError: shebang is not a function"},{"fix":"Add #!/usr/bin/env node as first line of entry file, or provide shebang option: shebang({ shebang: '#!/usr/bin/env node' }).","cause":"Entry file does not start with #!, and no explicit shebang option was provided.","error":"Error: No shebang found in entry file 'cli.js'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}