One of the common error many developers coming across recently while trying to run a front end framework such as Angular 13+, React JS, Next JS, Gatsby etc., using Node JS 17+ is 0308010C:digital envelope routines::unsupported. While there are many websites out there providing solutions to solve this error, there are almost none telling the reason for the error. In this post we will see what is this error and also how to solve it.

What is 0308010C:digital envelope routines::unsupported Error ?

The Error is causing because of Node JS. and is related to OpenSSL. 12.x, 14.x and 16.x versions of Node JS uses OpenSSL v.1.1.1. Recently (Sept 2021) OpenSSL released its newer version OpenSSL 3.0 which is a major release and is not completely backward compatible. Node JS 17 which was announced in October 2021 supports OpenSSL 3.0.

If you have created an application using an earlier version of Node JS, then if you have updated your Node JS to 17+ version, then you come across the error 0308010C:digital envelope routines::unsupported

How to Solve 0308010C:digital envelope routines::unsupported Error in Angular or React JS or Next JS or any other framework

Solution 1:

Since OpenSSL 3.0 is not completely backward compatible, Node JS in its version 17.0 which supports OpenSSL 3.0 also released a command line option –openssl-legacy-provider using which you can run your application with the legacy OpenSSL options.

To use it you can configure your package.json file like this

for Angular applications (make sure that you use npm start to run the application after making changes, since ng serve will still give you the error)

"start": "set NODE_OPTIONS=--openssl-legacy-provider && ng serve ",

for React Applications

"start": "react-scripts --openssl-legacy-provider start"

for Next JS

"scripts": {...
"start": "SET NODE_OPTIONS=--openssl-legacy-provider && next start",
"dev": "export NODE_OPTIONS=--openssl-legacy-provider; next dev", "build": "SET NODE_OPTIONS=--openssl-legacy-provider && next build"
... }, 

For other frameworks also, the solution will be almost similar. As you see that, with this solution, you are making your old application run with latest Node JS using a workaround openssl-legacy-provider. So, you can consider this solution as a temporary solution.

Solution 2:

Revert your Node JS version to an earlier version. As Node JS 17+ supports OpenSSL 3.0, you need to install a version of Node JS that uses an earlier version of OpenSSL.

Solution 3:

Re-build your entire application using the latest version of Node JS.