{"id":20768,"library":"webpack-format-messages","title":"webpack-format-messages","description":"Beautiful formatting for Webpack messages, ported from Create React App. Version 3.0.1 is the current stable release, with TypeScript definitions and native ESM support via the `exports` map. This package extracts and prettifies Webpack error and warning messages from a stats object, providing clean console output similar to Create React App. It differs from `react-dev-utils/formatWebpackMessages` by accepting a Webpack stats object directly (not the toJson() output) and by being a lightweight standalone install (under 10 kB) without the heavy `react-dev-utils` dependency. Key differentiators: zero browser dependency, pure Node.js environment, and a simple API with two functions (`formatMessages` and `formatMessage`). Release cadence is sporadic; last major release was v3.0.0 with breaking changes to Node.js 13.0-13.7 support.","status":"active","version":"3.0.1","language":"javascript","source_language":"en","source_url":"https://github.com/lukeed/webpack-format-messages","tags":["javascript","create-react-app","console","messages","webpack","pretty","format","stats","output","typescript"],"install":[{"cmd":"npm install webpack-format-messages","lang":"bash","label":"npm"},{"cmd":"yarn add webpack-format-messages","lang":"bash","label":"yarn"},{"cmd":"pnpm add webpack-format-messages","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"used for colorizing output messages","package":"kleur","optional":false}],"imports":[{"note":"Default export since v1; named export also available but default is preferred. ESM entry via exports map; Node 13.0-13.7 may need additional flags.","wrong":"const formatMessages = require('webpack-format-messages').default","symbol":"formatMessages","correct":"import formatMessages from 'webpack-format-messages'"},{"note":"Named export works in CJS. Default export also available as module.exports; the named export is the same function.","wrong":"const formatMessages = require('webpack-format-messages')","symbol":"formatMessages","correct":"const { formatMessages } = require('webpack-format-messages')"},{"note":"This is a named export, not default. Use destructuring to access it.","wrong":"import formatMessage from 'webpack-format-messages'","symbol":"formatMessage","correct":"import { formatMessage } from 'webpack-format-messages'"}],"quickstart":{"code":"const webpack = require('webpack');\nconst formatMessages = require('webpack-format-messages');\n\nconst compiler = webpack({\n  // minimal config\n  entry: './src/index.js',\n  mode: 'development',\n});\n\ncompiler.hooks.done.tap('report', (stats) => {\n  const messages = formatMessages(stats);\n  if (messages.errors.length) {\n    console.log('Errors:\\n' + messages.errors.join('\\n'));\n  }\n  if (messages.warnings.length) {\n    console.log('Warnings:\\n' + messages.warnings.join('\\n'));\n  }\n});\n\ncompiler.run((err) => { if (err) console.error(err); });","lang":"javascript","description":"Creates a Webpack compiler, taps the done hook, and uses formatMessages to pretty-print errors and warnings."},"warnings":[{"fix":"Upgrade to Node >= 13.8 or use `--experimental-exports` flag, or downgrade to v2.x.","message":"Node.js 13.0 - 13.7 users may experience import errors due to the `exports` map added in v3.0.0.","severity":"breaking","affected_versions":">=3.0.0 <3.0.0"},{"fix":"Use `const { formatMessages } = require('webpack-format-messages')` or `import formatMessages from ...`.","message":"Use of CommonJS require without destructuring may rely on the default export, which is deprecated in favor of named exports for clarity.","severity":"deprecated","affected_versions":">=3.0.0"},{"fix":"Pass the raw stats object from the done callback (the argument provided to the hook).","message":"The function expects a Webpack `stats` object, not the JSON from `stats.toJson()`.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Run `npm install --save-dev webpack-format-messages`","cause":"Package not installed or not in node_modules.","error":"Cannot find module 'webpack-format-messages'"},{"fix":"Use `import formatMessages from 'webpack-format-messages'` or `const { formatMessages } = require('webpack-format-messages')`","cause":"Importing the wrong export: default vs named.","error":"TypeError: formatMessages is not a function"},{"fix":"Upgrade Node to >= 14, or use dynamic import(`webpack-format-messages`) or set `type: 'module'` in package.json.","cause":"Node.js version < 12 or missing `--experimental-require-module` flag; package has ESM exports map.","error":"Error [ERR_REQUIRE_ESM]: require() of ES Module not supported"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}