Replace rollup-plugin-uglify


When upgrading my npm package dependencies, I encountered an error with the rollup upgrade:

$ npm install
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! Found: rollup@2.33.3
npm ERR! node_modules/rollup
npm ERR!   dev rollup@"^2.12.1" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer rollup@">=0.66.0 <2" from rollup-plugin-uglify@6.0.4
npm ERR! node_modules/rollup-plugin-uglify
npm ERR!   dev rollup-plugin-uglify@"^6.0.4" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.

I discovered that rollup-plugin-uglify was no longer compatible with rollup 2 (see issue).

The recommendation was to replace rollup-plugin-uglify with rollup-plugin-terser.

Luckily, the process was straightforward.


Install rollup-plugin-terser and remove rollup-plugin-uglify:

$ npm i rollup-plugin-terser -D && npm rm rollup-plugin-uglify -D

Update rollup.config.js:

 // rollup.config.js
-import { uglify } from 'rollup-plugin-uglify';
+import { terser } from 'rollup-plugin-terser';

 const config = {
   // ...
-  plugins: [uglify()],
+  plugins: [terser()],

 export default config;


Please support this site and join our Discord!