If you’re working on an Angular project and suddenly encounter the error:
Error: error:0308010C:digital envelope routines::unsupported
This issue is common with newer versions of
Node.js (v17+), especially
Node.js v22, due to changes in
OpenSSL 3.0. Below, we explain what causes it and how to fix it easily.
🔍 Why This Error Happens
From Node.js v17 onward, OpenSSL 3.0 is used by default, which no longer supports certain older cryptographic functions. Angular versions like Angular 11 (or older tooling) may still depend on these functions, causing the error to appear during script execution such as:
yarn start
npm run start
✅ The Solution: Use the OpenSSL Legacy Provider
To solve this issue, set the environment variable
NODE_OPTIONS=--openssl-legacy-provider. This tells Node.js to allow the older cryptographic methods required by some dependencies.
✍️ Step-by-Step Fix
1. Open your package.json file
Find the
"scripts" section. It might look like this:
"scripts": {
"start": "ng serve",
"build": "ng build"
}
2. Modify the scripts
Add the OpenSSL legacy provider to the scripts:
🟢 For Mac/Linux:
"scripts": {
"start": "NODE_OPTIONS=--openssl-legacy-provider ng serve",
"build": "NODE_OPTIONS=--openssl-legacy-provider ng build"
}
🟠 For Windows:
"scripts": {
"start": "set NODE_OPTIONS=--openssl-legacy-provider && ng serve",
"build": "set NODE_OPTIONS=--openssl-legacy-provider && ng build"
}
💡 Pro Tip: Repeat the same for other custom scripts like
test or
i18n if they also fail.
🧪 Test Your Fix
Now run your Angular app again:
yarn start
If the error disappears and your app runs, the fix worked!
💬 Conclusion
Node.js updates offer better performance and security, but they can also break compatibility with older frameworks like Angular 11. This error is easily resolved by enabling the legacy OpenSSL provider.
📌 Tip: For long-term stability, consider upgrading your Angular project to a more recent version fully compatible with Node.js v22+.
Related