{"id":15494,"library":"warnings-to-errors-webpack-plugin","title":"Webpack Warnings to Errors Plugin","description":"The `warnings-to-errors-webpack-plugin` is a utility for Webpack that elevates all build warnings to errors, ensuring a stricter compilation process. This plugin is currently at version 2.3.0 and is actively maintained, primarily releasing updates to ensure compatibility with new major versions of Webpack or to incorporate enhanced filtering capabilities. Its core differentiator is enforcing a zero-warning policy, which is particularly beneficial in continuous integration/continuous deployment (CI/CD) environments where subtle build warnings could otherwise be overlooked, potentially leading to runtime issues. It integrates seamlessly with Webpack's native `warningsFilter` and `ignoreWarnings` options, allowing developers to selectively exempt certain warnings from being promoted to errors.","status":"active","version":"2.3.0","language":"javascript","source_language":"en","source_url":"https://github.com/taehwanno/warnings-to-errors-webpack-plugin","tags":["javascript","webpack","plugin","webpack-plugin","typescript"],"install":[{"cmd":"npm install warnings-to-errors-webpack-plugin","lang":"bash","label":"npm"},{"cmd":"yarn add warnings-to-errors-webpack-plugin","lang":"bash","label":"yarn"},{"cmd":"pnpm add warnings-to-errors-webpack-plugin","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency, required for Webpack build process.","package":"webpack","optional":false}],"imports":[{"note":"CommonJS `require` is the most common usage shown in documentation. For ESM, use default import.","wrong":"import WarningsToErrorsPlugin from 'warnings-to-errors-webpack-plugin';","symbol":"WarningsToErrorsPlugin","correct":"const WarningsToErrorsPlugin = require('warnings-to-errors-webpack-plugin');"},{"note":"This plugin exports a class as its default, not as a named export. TypeScript users will typically use this import style.","wrong":"import { WarningsToErrorsPlugin } from 'warnings-to-errors-webpack-plugin';","symbol":"WarningsToErrorsPlugin","correct":"import WarningsToErrorsPlugin from 'warnings-to-errors-webpack-plugin';"},{"note":"The package ships TypeScript type definitions, enabling type-safe usage and autocompletion.","symbol":"WarningsToErrorsPlugin (TypeScript Type)","correct":"import WarningsToErrorsPlugin from 'warnings-to-errors-webpack-plugin';\n// ...\nconst plugin: WarningsToErrorsPlugin = new WarningsToErrorsPlugin();"}],"quickstart":{"code":"const WarningsToErrorsPlugin = require('warnings-to-errors-webpack-plugin');\n\nmodule.exports = {\n  mode: 'development',\n  entry: './src/index.js',\n  output: {\n    filename: 'bundle.js',\n    path: require('path').resolve(__dirname, 'dist'),\n  },\n  plugins: [\n    new WarningsToErrorsPlugin(),\n  ],\n  // Example for Webpack 5 ignoring a specific warning pattern\n  ignoreWarnings: [\n    { message: /Critical dependency: the request of a dependency is an expression/ }\n  ],\n  // For Webpack v2, v3, and v4, use stats.warningsFilter instead of ignoreWarnings\n  // stats: {\n  //   warningsFilter: [/some warning pattern/]\n  // }\n};","lang":"javascript","description":"Demonstrates basic setup, converting all Webpack warnings into errors, and how to ignore specific warnings in Webpack 5."},"warnings":[{"fix":"Verify your Webpack version against the `peerDependencies` field of the `warnings-to-errors-webpack-plugin` in your `node_modules` directory or on npmjs.com for exact compatibility. The plugin generally supports a wide range of Webpack versions.","message":"The `peerDependencies` of `warnings-to-errors-webpack-plugin` (`^2.2.0-rc || ^3 || ^4 || ^5`) indicate broad compatibility across Webpack versions 2 through 5. However, older documentation or general 'Breaking Changes' sections might state a requirement for `webpack >= 4.0.0`, which can be confusing. Always refer to the `peerDependencies` in `package.json` for the most accurate compatibility information.","severity":"gotcha","affected_versions":"all"},{"fix":"For Webpack 5, use the `ignoreWarnings` array in your top-level Webpack configuration: `module.exports = { ignoreWarnings: [{ message: /pattern/ }] };`. Avoid `stats.warningsFilter` in Webpack 5.","message":"Webpack 5 deprecated `stats.warningsFilter` in favor of the new `ignoreWarnings` option. While the plugin is designed to work with both, projects upgrading to Webpack 5 should migrate their warning exclusion logic from `stats.warningsFilter` to `ignoreWarnings` for future compatibility and best practice.","severity":"breaking","affected_versions":">=2.1.0"},{"fix":"Ensure all team members are aware of the strict build policy. Proactively address all existing warnings or configure `ignoreWarnings` (Webpack 5) or `stats.warningsFilter` (Webpack 2-4) to explicitly allow specific non-critical warnings.","message":"Enabling this plugin fundamentally changes Webpack's error reporting. Any warning, no matter how minor, will halt the build process with an error exit code. This is the plugin's intended behavior but can be unexpected if developers are not accustomed to a strict build environment, potentially failing CI/CD pipelines that previously passed with warnings.","severity":"gotcha","affected_versions":"all"},{"fix":"For Webpack v4/v5, configure `optimization: { noEmitOnErrors: true }`. For Webpack v2/v3, ensure `new webpack.NoEmitOnErrorsPlugin()` is included in your `plugins` array alongside `WarningsToErrorsPlugin`.","message":"When using this plugin to prevent asset emission on warnings, the configuration differs between Webpack versions. For Webpack v4 and v5, you should use `optimization.noEmitOnErrors: true`. For older versions (v2 and v3), you need to explicitly add `new webpack.NoEmitOnErrorsPlugin()` to your plugins array.","severity":"gotcha","affected_versions":"<4.0"}],"env_vars":null,"last_verified":"2026-04-21T00:00:00.000Z","next_check":"2026-07-20T00:00:00.000Z","problems":[{"fix":"Ensure you are using `new WarningsToErrorsPlugin()` in your `plugins` array. If using CommonJS, use `const WarningsToErrorsPlugin = require('warnings-to-errors-webpack-plugin');`. For ESM, use `import WarningsToErrorsPlugin from 'warnings-to-errors-webpack-plugin';`.","cause":"The plugin class was not correctly imported or instantiated in the Webpack configuration.","error":"TypeError: WarningsToErrorsPlugin is not a constructor"},{"fix":"Install the package as a development dependency: `npm install --save-dev warnings-to-errors-webpack-plugin` or `yarn add -D warnings-to-errors-webpack-plugin`.","cause":"The package `warnings-to-errors-webpack-plugin` is not installed or not resolvable by Node.js.","error":"Module not found: Error: Can't resolve 'warnings-to-errors-webpack-plugin'"},{"fix":"Examine the detailed error output to identify the specific warnings. Either fix the underlying cause of the warning in your code or add a rule to `ignoreWarnings` (Webpack 5) or `stats.warningsFilter` (Webpack 2-4) in your Webpack configuration to explicitly suppress that warning.","cause":"The `warnings-to-errors-webpack-plugin` successfully promoted one or more Webpack warnings into critical errors, halting the build.","error":"Webpack compilation failed with errors. (followed by a list of 'Module Warning (from ...)' entries)"}],"ecosystem":"npm"}