{"id":20188,"library":"license-webpack-plugin","title":"License Webpack Plugin","description":"A webpack plugin that extracts third-party library license information and outputs it to a file or adds a banner. Current stable version is 4.0.2. It supports webpack 4 and 5, outputs licenses per chunk or aggregated, and allows exclusion/inclusion patterns. Compared to alternatives, it offers comprehensive configuration for license compliance in webpack builds.","status":"active","version":"4.0.2","language":"javascript","source_language":"en","source_url":"ssh://git@github.com/xz64/license-webpack-plugin","tags":["javascript","license","plugin","webpack","typescript"],"install":[{"cmd":"npm install license-webpack-plugin","lang":"bash","label":"npm"},{"cmd":"yarn add license-webpack-plugin","lang":"bash","label":"yarn"},{"cmd":"pnpm add license-webpack-plugin","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"required as peer dependency to integrate with webpack build system","package":"webpack","optional":false}],"imports":[{"note":"CommonJS require must destructure the named export 'LicenseWebpackPlugin'.","wrong":"const LicenseWebpackPlugin = require('license-webpack-plugin');","symbol":"LicenseWebpackPlugin","correct":"const { LicenseWebpackPlugin } = require('license-webpack-plugin');"},{"note":"ESM import must use named import. Default export does not exist.","wrong":"import LicenseWebpackPlugin from 'license-webpack-plugin';","symbol":"LicenseWebpackPlugin","correct":"import { LicenseWebpackPlugin } from 'license-webpack-plugin';"},{"note":"TypeScript type import for configuration object (only needed when using TypeScript).","wrong":"","symbol":"PluginOptions","correct":"import { PluginOptions } from 'license-webpack-plugin';"}],"quickstart":{"code":"const { LicenseWebpackPlugin } = require('license-webpack-plugin');\nmodule.exports = {\n  plugins: [\n    new LicenseWebpackPlugin({\n      outputFilename: 'licenses.txt',\n      unacceptableLicenseTest: (licenseType) => licenseType === 'GPL' || licenseType === 'AGPL',\n      renderLicenses: (modules) => modules.map(m => `Package: ${m.name} - License: ${m.licenseId}`).join('\\n'),\n    })\n  ]\n};","lang":"javascript","description":"Creates a webpack plugin instance that writes a licenses.txt file, marks GPL and AGPL licenses as unacceptable, and customizes the license output format."},"warnings":[{"fix":"Manually specify additional modules using the `additionalModules` option.","message":"The plugin does not automatically scan packages imported via SASS @import or other non-JS modules.","severity":"gotcha","affected_versions":"all"},{"fix":"Upgrade webpack to version 4 or 5, or use an older version of the plugin (e.g., 2.x) for webpack 3.","message":"Requires webpack 4 or 5; not compatible with webpack 3 or earlier.","severity":"gotcha","affected_versions":">=4.0.0"},{"fix":"Set `addBanner: false` in plugin options to suppress banner injection.","message":"Default output adds a banner to all JavaScript assets; may conflict with CSP (Content Security Policy).","severity":"gotcha","affected_versions":"all"},{"fix":"Update import from default import to named import: `const { LicenseWebpackPlugin } = require('license-webpack-plugin')`","message":"Version 4.x changed default export to named export 'LicenseWebpackPlugin'.","severity":"breaking","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":"Use `const { LicenseWebpackPlugin } = require('license-webpack-plugin')` or `import { LicenseWebpackPlugin } from 'license-webpack-plugin'`","cause":"Using default import/require without destructuring (e.g., `const LicenseWebpackPlugin = require('license-webpack-plugin')`)","error":"TypeError: LicenseWebpackPlugin is not a constructor"},{"fix":"Run `npm install --save-dev license-webpack-plugin`","cause":"The package is not installed or installed as devDependency incorrectly.","error":"Error: Cannot find module 'license-webpack-plugin'"},{"fix":"Use `licenseTypeOverrides` option to manually specify licenses for such packages.","cause":"Certain packages do not include license information in their package.json.","error":"No license information found for some modules"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}