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
muslnode 18–226 runs
build_error
glibcnode 18–226 runs
build_error
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
StylusLoader
✓ import stylusLoader from 'stylus-loader'
✗ const stylusLoader = require('stylus-loader')
CommonJS require works but default export is typically used as loader string, not imported programmatically.
Webpack config
✓ {
test: /\.styl$/,
loader: 'stylus-loader'
}
✗ {
test: /\.styl$/,
use: 'stylus-loader'
}
Both work, but 'loader' is more concise when no other loaders are chained.
stylusOptions
✓ {
test: /\.styl$/,
use: [{
loader: 'stylus-loader',
options: {
stylusOptions: { /* ... */ }
}
}]
}
✗ {
test: /\.styl$/,
use: [{
loader: 'stylus-loader',
options: { /* stylus options directly */ }
}]
}
Stylus options must be nested under 'stylusOptions' key, not flattened.
Basic webpack configuration to load Stylus files with style-loader, css-loader, and stylus-loader, including source maps.
// webpack.config.js
const path = require('path');
module.exports = {
mode: 'development',
entry: './src/style.styl',
output: { path: path.resolve(__dirname, 'dist'), filename: 'bundle.js' },
module: {
rules: [
{
test: /\.styl$/,
use: [
{ loader: 'style-loader' },
{ loader: 'css-loader', options: { sourceMap: true } },
{ loader: 'stylus-loader', options: { stylusOptions: { compress: false } } }
]
}
]
}
};
Errors
Common errors & fixes
Error: Module build failed (from ./node_modules/stylus-loader/dist/cjs.js):
TypeError: Cannot read properties of undefined (reading 'stylus')
Stylus is not installed or not a peer dependency
fixnpm install stylus --save-dev
Error: Node.js version 14.15.0 is not supported. Please upgrade to Node.js 18.12.0 or higher.
Using stylus-loader v8 with older Node.js
fixUpgrade Node.js to 18.12.0+
Warning: The define option as an object is deprecated. Use array syntax.
Using object syntax for `define` in stylusOptions
fixChange to array: `define: [['var', value, raw]]`
Audit
Dependencies
stylusrequiredCompiles Stylus to CSS
webpackrequiredLoader integration