Solving Node.js Terser Plugin Error: `Digital Envelope Routines::Unsupported`



If you’re encountering a Terser plugin error related to “digital envelope routines::unsupported” during your build process with Node.js, especially versions 17 and above, a quick workaround is to set the NODE_OPTIONS environment variable to --openssl-legacy-provider. This can be done by running $env:NODE_OPTIONS="--openssl-legacy-provider" in your terminal (PowerShell for Windows users) before initiating your build command. This solution helps bypass the compatibility issues with OpenSSL 3.0 in newer Node.js versions, allowing your build to complete successfully.


In the midst of reviving the ESP-IDF example to incorporate a Vue 2 and Vuetify front end for an ESP32 web application, I encountered a peculiar issue.

The project aimed to build a webpage that would later be flashed to the ESP32, serving as a modern interface for interacting with the device. Following the outlined steps, I navigated to the ./front/web-blinker directory, installed the necessary dependencies with npm install, and initiated the build process using npm run build.e

This project serves as an enhanced version of the ESP-IDF’s RESTful server example. It’s an ideal setup for developing applications requiring a RESTful API server alongside a sophisticated UI.

However, during the build, an unexpected error surfaced, related to the Terser plugin and division deprecation warnings from Dart Sass. The Terser plugin error, in particular, was perplexing, hindering the build process and posing a significant obstacle to progress. This issue was especially surprising given the straightforward nature of the task at hand—building a static web page for deployment to an ESP32 module.

Symptom/Error Encountered

During the build process of a web application, you might encounter a failure with a series of errors stemming from the Terser plugin, a tool used for minifying JavaScript. The error message prominently includes:

Error: error:0308010C:digital envelope routines::unsupported

This issue particularly affects projects after upgrading to Node.js version 17 or newer due to changes in the cryptographic library (OpenSSL 3.0) that Node.js uses. The Terser plugin, along with other dependencies that rely on OpenSSL for encryption or hashing, may not be fully compatible with these changes, leading to the aforementioned build errors.

The Solution

To resolve this issue, you can use the --openssl-legacy-provider flag with Node.js to switch back to the legacy provider for OpenSSL. This flag is a temporary measure that allows your projects to build successfully by bypassing the incompatibilities introduced with OpenSSL 3.0.

For Shell users, the command is as follows:

export NODE_OPTIONS=--openssl-legacy-provider

For Windows PowerShell (PowerShell.exe) users, the command is as follows:


For Windows Command Prompt (cmd.exe) users, the command is as follows:

set NODE_OPTIONS=--openssl-legacy-provider

After setting this environment variable, proceed with your build command, typically npm run build or a similar script defined in your package.json. This should allow the build process to complete without encountering the Terser plugin error.

Additional Notes

  • It’s important to note that this workaround is intended as a temporary fix. Keep an eye on updates from Node.js, the Terser plugin, and other related dependencies for more permanent solutions.
  • Ensure to test your application thoroughly after the build to verify that the use of the legacy provider does not introduce any new issues.
  • If you’re working in a team or on a continuous integration (CI) system, make sure to document this workaround and communicate it clearly to avoid build inconsistencies.

This workaround provides a quick and effective way to deal with specific build errors related to OpenSSL 3.0 incompatibilities in Node.js projects. By applying this fix, you can ensure your project’s build process remains smooth and uninterrupted while waiting for long-term solutions from dependency maintainers.