Registry /
devops / terser-webpack-plugin-legacy
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslnode 18–226 runs
build_error
glibcnode 18–226 runs
build_error
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
TerserPlugin
✓ const TerserPlugin = require('terser-webpack-plugin-legacy');
✗ import TerserPlugin from 'terser-webpack-plugin-legacy';
CJS only; no default ESM export in this legacy version.
TerserPlugin (as named export)
✓ const { TerserPlugin } = require('terser-webpack-plugin-legacy');
✗ const { TerserPlugin } = require('terser-webpack-plugin');
Note: package name is terser-webpack-plugin-legacy, not terser-webpack-plugin. Also, it's a default export, not named.
Plugin options
✓ new (require('terser-webpack-plugin-legacy'))({ cache: true })
✗ new (require('terser-webpack-plugin'))({ cache: true })
Common mistake: using wrong package name. Ensure version 1.x for webpack 3.
Sets up terser-webpack-plugin-legacy in webpack 3 config with cache enabled and console removal.
const TerserPlugin = require('terser-webpack-plugin-legacy');
module.exports = {
context: __dirname,
entry: './src/index.js',
output: {
path: __dirname + '/dist',
filename: 'bundle.js'
},
optimization: {
minimizer: [
new TerserPlugin({
test: /\.js(\?.*)?$/i,
cache: true,
terserOptions: {
compress: {
drop_console: true
}
}
})
]
}
};
Errors
Common errors & fixes
Module not found: Error: Can't resolve 'terser-webpack-plugin'
Incorrect package name; installed the wrong package or not installed.
fixRun: npm install terser-webpack-plugin-legacy --save-dev
TypeError: Cannot read property 'tapAsync' of undefined
Plugin incompatible with webpack 4+ because it uses webpack 3 hooks.
fixUse terser-webpack-plugin (non-legacy) for webpack 4+.
Error: webpack.optimize.UglifyJsPlugin is not a constructor
Misunderstanding: using UglifyJsPlugin when terser plugin should be used.
fixUse TerserPlugin from 'terser-webpack-plugin-legacy' instead.
Audit
Dependencies
webpackrequiredpeer dependency