{"id":22152,"library":"rollup-plugin-onerror","title":"rollup-plugin-onerror","description":"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.","status":"active","version":"1.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/ashubham/rollup-plugin-onerror","tags":["javascript","rollup","plugin","onerror","error","failure"],"install":[{"cmd":"npm install rollup-plugin-onerror","lang":"bash","label":"npm"},{"cmd":"yarn add rollup-plugin-onerror","lang":"bash","label":"yarn"},{"cmd":"pnpm add rollup-plugin-onerror","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Package ships a CommonJS default export, not named exports. ESM import is default.","wrong":"const { onError } = require('rollup-plugin-onerror')","symbol":"onError","correct":"import onError from 'rollup-plugin-onerror'"},{"note":"In CJS, require returns the default export directly.","wrong":"const { default: onError } = require('rollup-plugin-onerror')","symbol":"default","correct":"const onError = require('rollup-plugin-onerror')"},{"note":"Named import is incorrect; it's a default export.","wrong":"import { onError } from 'rollup-plugin-onerror'","symbol":"onError","correct":"import onError from 'rollup-plugin-onerror'"}],"quickstart":{"code":"// rollup.config.js\nimport onError from 'rollup-plugin-onerror'\n\nexport default {\n  input: 'src/index.js',\n  output: { file: 'dist/bundle.js', format: 'es' },\n  plugins: [\n    onError((err) => {\n      console.log('Build failed:', err.message)\n    })\n  ]\n}","lang":"javascript","description":"Basic setup: install, import as default, and pass a callback to handle build errors."},"warnings":[{"fix":"If you need to suppress exit code, use a different plugin or modify process.exitCode within the callback.","message":"Plugin runs callback but does not prevent Rollup from exiting with non-zero code on error.","severity":"gotcha","affected_versions":"1.0.0"},{"fix":"Access err.stack for more context. Consider wrapping the error if additional info is needed.","message":"Callback receives the Error object directly; no additional context (e.g., plugin name, file) is provided.","severity":"gotcha","affected_versions":"1.0.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Change to 'import onError from 'rollup-plugin-onerror''","cause":"Using named import instead of default import in ESM.","error":"TypeError: onError is not a function"},{"fix":"Use the function directly in the plugins array, not as a hook name.","cause":"Misunderstanding the plugin as a Rollup hook rather than a regular function.","error":"Error: The hook 'onError' is not supported by rollup-plugin-onerror"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}