{"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,"search_vec":"'1':79 '1.0.1':24 '14':82 'activ':32 'allow':42 'altern':48 'auto':61 'auto-detect':60 'automat':10 'bundl':21 'configur':58 'current':26 'depend':86 'detect':62 'differenti':34 'entri':17,39,54,67 'explicit':72 'file':18,68 'handl':36 'hashbang':91 'javascript':87 'key':33 'level':31 'lightweight':83 'line':14 'mainten':30 'maintenance-level':29 'manual':57 'multi':38 'multi-entri':37 'node':81 'option':76 'output':22 'overrid':43 'plugin':3,8,75,89 'preserv':4,11 'requir':56 'rollup':2,7,78,88 'rollup-plugin-preserve-shebang':1 'set':73 'setup':40 'shebang':5,13,45,64,90 'singl':53 'stabl':27 'string':46 'support':77 'unlik':47 'version':23 'via':74 'work':51","created_at":"2026-04-27T17:03:49.053425+00:00","updated_at":"2026-04-27T17:03:49.053425+00:00","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,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/developit/rollup-plugin-preserve-shebang","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/rollup-plugin-preserve-shebang","openapi_spec":null,"status_page":null,"smithery":null,"categories":["devops"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-18","next_check":"2026-07-26","install_tag":null}}