Registry / devops / shebang-loader

shebang-loader

JSON →
library0.0.1jsnpmunverified

Webpack loader that strips the shebang (#!) line from script files, allowing them to be bundled as modules. Current version 0.0.1 is a minimal, unmaintained package with no releases since 2014. It only works with webpack 1.x and provides no configuration options. Not suitable for modern projects; alternatives include inline loader syntax or manual file transforms.

npm install shebang-loader
INSTALL
IMPORT
SIG · SHEBANG-LOADER
S
shebang-loader
devopsjavascriptv0.0.1
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 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

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

default (loader)
import script from 'shebang-loader!./file.js';
import script from 'shebang!./file.js';
The exclamation mark syntax is used before the resource; some users mistakenly omit '!.' or use 'loader!' syntax wrong.
shebang-loader (config entry)
module.exports = { module: { rules: [ { test: /\.js$/, use: 'shebang-loader' } ] } }
module.exports = { module: { loaders: [ { test: /\.js$/, loader: 'shebang-loader' } ] } }
Webpack 1 uses 'loaders' array, modern webpack uses 'rules'. The package is from webpack 1 era.
require (CommonJS)
var script = require('shebang-loader!./file.js');
var script = require('shebang!./file.js');
Users often forget the '-loader' suffix.

Webpack config to strip shebang from .js files and an example requiring a CLI script.

// webpack.config.js module.exports = { module: { rules: [ { test: /\.js$/, use: 'shebang-loader' } ] } }; // Now require a CLI script with a shebang line // bin/hello.js: #!/usr/bin/env node\nconsole.log('Hello'); const hello = require('shebang-loader!./bin/hello.js'); console.log(hello); // 'Hello'
Debug
Known issues
gotchaThe shebang-loader only works with webpack 1.x. In webpack 2+, it is not officially supported and may cause errors.
fix
Use webpack 1 or manually strip shebang with a preprocessor. Consider using a custom loader or the 'imports-loader' with shebang removal.
affects: >=0.0.1
deprecatedPackage has no updates since 2014 and is effectively abandoned. It does not support modern webpack versions (2, 3, 4, 5).
fix
Replace with a custom webpack loader that uses regex to remove shebang lines, or use an alternative package like 'strip-loader'.
affects: >=0.0.1
gotchaThe loader only strips lines that start with '#!', but does not handle files that have no shebang, causing no issues. However, it may not remove carriage return characters on Windows line endings.
fix
If on Windows, ensure line endings are Unix-style (LF) or modify the loader to handle CRLF.
affects: >=0.0.1
Errors
Common errors & fixes
Module not found: Error: Can't resolve 'shebang-loader'
shebang-loader is not installed or the loader name is misspelled.
fix
Run 'npm install shebang-loader --save-dev' and use correct loader name: 'shebang-loader' (not 'shebang').
Error: Shebang loader is used but the file does not have a shebang
The loader expects a shebang line; if missing, it may error (depends on implementation).
fix
Ensure files have a shebang line, or remove the loader rule for files without shebangs.
BREAKING CHANGE: webpack < 5 used to include polyfills for node.js built-in modules...
Using shebang-loader with modern webpack may trigger compatibility warnings due to polyfill removal.
fix
Use webpack 1 or avoid shebang-loader; it is not maintained for newer webpack versions.
Upgrade
Version history
0.0.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
10 hits · last 30 days
node
10
Resources
shebang-loader — npm install shebang-loader · libregistry