{"id":21911,"library":"rollup-plugin-add-shebang","title":"rollup-plugin-add-shebang","description":"Rollup plugin that prepends a shebang line (e.g., #!/usr/bin/env node) to output files. v0.3.1 is the latest stable release (last updated July 2019). It automatically adds shebangs to matched files after bundling, supporting include/exclude patterns and custom shebang strings or functions. Unlike alternatives, it works with code splitting and doesn't require modifying source files. Currently in maintenance mode with no recent updates.","status":"maintenance","version":"0.3.1","language":"javascript","source_language":"en","source_url":"https://github.com/ls-age/rollup-plugin-add-shebang","tags":["javascript","rollup","plugin","add","shebang","cli","typescript"],"install":[{"cmd":"npm install rollup-plugin-add-shebang","lang":"bash","label":"npm"},{"cmd":"yarn add rollup-plugin-add-shebang","lang":"bash","label":"yarn"},{"cmd":"pnpm add rollup-plugin-add-shebang","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency – plugin is designed to work as a Rollup plugin","package":"rollup","optional":false}],"imports":[{"note":"Package exports a default function. Named import will not work.","wrong":"import { shebang } from 'rollup-plugin-add-shebang'","symbol":"default (shebang)","correct":"import shebang from 'rollup-plugin-add-shebang'"},{"note":"CJS users must use .default because the package uses ESM internally.","wrong":"const shebang = require('rollup-plugin-add-shebang')","symbol":"shebang (CommonJS)","correct":"const shebang = require('rollup-plugin-add-shebang').default"},{"note":"Package ships TypeScript types, so ESM import is preferred.","wrong":"import shebang = require('rollup-plugin-add-shebang')","symbol":"TypeScript","correct":"import shebang from 'rollup-plugin-add-shebang'"}],"quickstart":{"code":"// rollup.config.js\nimport shebang from 'rollup-plugin-add-shebang';\n\nexport default {\n  input: 'src/index.js',\n  output: {\n    dir: 'dist',\n    format: 'cjs'\n  },\n  plugins: [\n    shebang({\n      include: ['**/cli.js', '**/bin.js'],\n      exclude: '**/node_modules/**',\n      shebang: '#!/usr/bin/env node'\n    })\n  ]\n};","lang":"javascript","description":"Configures Rollup to add a Node.js shebang to output files matching cli.js or bin.js patterns."},"warnings":[{"fix":"Always start shebang with #! and ensure correct interpreter path.","message":"Plugin does not validate shebang content; invalid shebangs (e.g., missing #!) will silently produce broken executables.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Refer to changelog for function signature; the function receives the file path and should return a string.","message":"The shebang option can be a function in v0.3.0+, but this is not documented in the README.","severity":"deprecated","affected_versions":">=0.3.0"},{"fix":"Use source-level shebangs or another plugin if you need shebangs in source files.","message":"Plugin only runs on output files after bundling; it cannot be used to modify input files.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Set output.format to 'cjs' or 'umd' when targeting Node.js CLI tools.","message":"If output.format is 'es' or 'iife', the shebang may be placed correctly but the module may not be directly executable; only CJS/UMD formats are reliably executable with Node.js shebang.","severity":"gotcha","affected_versions":">=0.1.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Pass a string like '#!/usr/bin/env node' or a function returning a string.","cause":"Provided a non-string/non-function value (e.g., number, null, or object) to the shebang option.","error":"Error: Invalid shebang option. Must be a string or a function that returns a string."},{"fix":"Use default import: import shebang from 'rollup-plugin-add-shebang'","cause":"Imported the package incorrectly (e.g., using named import { shebang }) in an ESM context.","error":"TypeError: shebang is not a function"},{"fix":"Run npm install --save-dev rollup-plugin-add-shebang","cause":"Package not installed or missing from dependencies.","error":"Error: Could not resolve 'rollup-plugin-add-shebang'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}