{"id":20787,"library":"webpack-license-plugin","title":"webpack-license-plugin","description":"A webpack plugin that extracts open source license information from npm packages in your webpack output. Current stable version is 4.5.1, released with regular updates. It supports webpack 2 through 5 and helps generate a bill of materials in JSON, HTML, CSV, or custom formats. Key differentiators include built-in license policy enforcement (fail on unacceptable licenses), exclusion of internal packages, and full test coverage. Since v4.4.1, the package ships both ESM and CJS builds with TypeScript types, and requires Node >=16.","status":"active","version":"4.5.1","language":"javascript","source_language":"en","source_url":"https://github.com/codepunkt/webpack-license-plugin","tags":["javascript","webpack","build","artifact","oss","open source","compliance","copyright","license","typescript"],"install":[{"cmd":"npm install webpack-license-plugin","lang":"bash","label":"npm"},{"cmd":"yarn add webpack-license-plugin","lang":"bash","label":"yarn"},{"cmd":"pnpm add webpack-license-plugin","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Webpack is a peer dependency required to run the plugin. Supports versions >=4.0.0 and <6.0.0.","package":"webpack","optional":false}],"imports":[{"note":"ESM default import is preferred since v4.4.1. CJS require still works via the package's CJS build.","wrong":"const LicensePlugin = require('webpack-license-plugin')","symbol":"LicensePlugin","correct":"import LicensePlugin from 'webpack-license-plugin'"},{"note":"TypeScript users can import the options interface for type checking.","wrong":null,"symbol":"LicensePluginOptions","correct":"import type { LicensePluginOptions } from 'webpack-license-plugin'"},{"note":"Type export for the output data type of the plugin.","wrong":null,"symbol":"PluginOutput","correct":"import type { PluginOutput } from 'webpack-license-plugin'"}],"quickstart":{"code":"// webpack.config.js\nimport LicensePlugin from 'webpack-license-plugin';\n\nexport default {\n  plugins: [\n    new LicensePlugin({\n      outputFilename: 'thirdPartyNotice.json',\n      unacceptableLicenseTest: (licenseIdentifier) =>\n        ['GPL', 'AGPL', 'LGPL', 'MPL'].includes(licenseIdentifier),\n      excludedPackageTest: (packageName) =>\n        packageName.startsWith('@mycompany/'),\n    }),\n  ],\n};","lang":"typescript","description":"Basic usage with options: output JSON, reject GPL-family licenses, exclude internal packages."},"warnings":[{"fix":"Upgrade Node to version 16 or later.","message":"Requires Node >=16 as of v4.5.0; earlier versions may work on Node 12 but are not supported.","severity":"breaking","affected_versions":">=4.5.0"},{"fix":"If you encounter stale license output, clear the webpack cache or configure the plugin to run on every build.","message":"The plugin taps into webpack's compilation hooks; if using webpack 5's persistent caching, ensure the plugin is not excluded from caching (it uses tapAsync which is cacheable by default).","severity":"gotcha","affected_versions":">=4.0.0"},{"fix":"Migrate to the new options schema (see README).","message":"The option `licenseOverrides` was used in earlier versions but is not documented in v4; instead use `additionalFiles` or custom output.","severity":"deprecated","affected_versions":"<4.0.0"},{"fix":"Set the `outputFormatter` option to a function that returns the desired format string.","message":"When using output format other than JSON, the custom renderer function must be provided – otherwise the plugin outputs JSON by default.","severity":"gotcha","affected_versions":">=4.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 -D webpack-license-plugin` or `yarn add -D webpack-license-plugin` and ensure your import uses the correct path.","cause":"The package is not installed or the import path is incorrect.","error":"Module not found: Error: Can't resolve 'webpack-license-plugin'"},{"fix":"Use `import LicensePlugin from 'webpack-license-plugin'` (default import) instead of `import { LicensePlugin } from 'webpack-license-plugin'`.","cause":"Using a named import instead of default import when importing from ESM.","error":"TypeError: LicensePlugin is not a constructor"},{"fix":"Install webpack: `npm install webpack` or `yarn add webpack`.","cause":"Webpack is not installed or is a peer dependency missing.","error":"Error: Cannot find module 'webpack'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}