Registry / devops / rollup-plugin-onerror

rollup-plugin-onerror

JSON →
library1.0.0jsnpmunverified

A Rollup plugin that runs a user-defined callback when the build encounters an error. Version 1.0.0 is the initial and only release. This is a minimal utility package with no dependencies. It differs from Rollup's built-in error handling by allowing custom side effects (e.g., logging, notifications) without altering the build's failure behavior.

npm install rollup-plugin-onerror
INSTALL
IMPORT
SIG · ROLLUP-PLUGIN-ONER
R
rollup-plugin-onerror
devopsjavascriptv1.0.0
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 18223 runs
build_error
glibc
node 18223 runs
build_error
Code
Verified usage

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

onError
import onError from 'rollup-plugin-onerror'
const { onError } = require('rollup-plugin-onerror')
Package ships a CommonJS default export, not named exports. ESM import is default.
default
const onError = require('rollup-plugin-onerror')
const { default: onError } = require('rollup-plugin-onerror')
In CJS, require returns the default export directly.
onError
import onError from 'rollup-plugin-onerror'
import { onError } from 'rollup-plugin-onerror'
Named import is incorrect; it's a default export.

Basic setup: install, import as default, and pass a callback to handle build errors.

// rollup.config.js import onError from 'rollup-plugin-onerror' export default { input: 'src/index.js', output: { file: 'dist/bundle.js', format: 'es' }, plugins: [ onError((err) => { console.log('Build failed:', err.message) }) ] }
Debug
Known issues
gotchaPlugin runs callback but does not prevent Rollup from exiting with non-zero code on error.
fix
If you need to suppress exit code, use a different plugin or modify process.exitCode within the callback.
affects: 1.0.0
gotchaCallback receives the Error object directly; no additional context (e.g., plugin name, file) is provided.
fix
Access err.stack for more context. Consider wrapping the error if additional info is needed.
affects: 1.0.0
Errors
Common errors & fixes
TypeError: onError is not a function
Using named import instead of default import in ESM.
fix
Change to 'import onError from 'rollup-plugin-onerror''
Error: The hook 'onError' is not supported by rollup-plugin-onerror
Misunderstanding the plugin as a Rollup hook rather than a regular function.
fix
Use the function directly in the plugins array, not as a hook name.
Upgrade
Version history
1.0.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
4 hits · last 30 days
node
4
Resources
rollup-plugin-onerror — npm install rollup-plugin-onerror · libregistry