I am building a Gatsby site. I upgraded Node.js to v17.0.1, and when I run a build, there is an error:
Error: digital envelope routines::unsupported opensslErrorStack: [ 'error:03000086:digital envelope routines::initialization error' ], library: 'digital envelope routines', reason: 'unsupported', code: 'ERR_OSSL_EVP_UNSUPPORTED'
If I downgrade it to v16, it works fine, and the build will be successful. How can I fix this?
From googling, this may be a similar issue: Error: error:06065064:digital envelope routines:EVP_DecryptFinal_ex:bad decrypt #48
The problem is because of an issue with webpack. Open your command prompt / terminal and run the following command After executing the command, now you can use ng serve command in your command prompt/ terminal which solves digital envelope routines unsupported error in Angular applications.
All you need to do is add the below line in your DockeFile to resolve the issue. The error:0308010C:digital envelope routines::unsupported occurs with the Node.js version 17 as it’s not the LTS version, and there is a breaking change in the OpenSSL.
This error is because node.js 17 uses OpenSSL3, which has changed code for initialization context of md family (including md4), and this is a breaking change. We can find more details about the OpenSSL3 upgrade over here. The Node JS version 17 is not the LTS (Long Term Support), and it is not compatible with the webpack version 4.
If you hit an ERR_OSSL_EVP_UNSUPPORTED error in your application with Node.js 17, it’s likely that your application or a module you’re using is attempting to use an algorithm or key size which is no longer allowed by default with OpenSSL 3.0.
This might help. Add these scripts in the package.json file.
"scripts": { "start": "export SET NODE_OPTIONS=--openssl-legacy-provider && react-scripts start", "build": "export SET NODE_OPTIONS=--openssl-legacy-provider && react-scripts build" }
or
"scripts": { "start": "react-scripts --openssl-legacy-provider start", "build": "react-scripts --openssl-legacy-provider build", }
"scripts": { "serve": "export NODE_OPTIONS=--openssl-legacy-provider && vue-cli-service serve", "build": "export NODE_OPTIONS=--openssl-legacy-provider && vue-cli-service build", "lint": "export NODE_OPTIONS=--openssl-legacy-provider && vue-cli-service lint" },
or
"scripts": { "serve": "vue-cli-service --openssl-legacy-provider serve", "build": "vue-cli-service --openssl-legacy-provider build", "lint": "vue-cli-service --openssl-legacy-provider lint" },
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With