WP Newsify

How to Resolve OpenSSL Error 0308010C in Webpack/Next.js Builds

Ever been deep in a Webpack or Next.js project, humming along, building your awesome app, when suddenly…

BOOM 💥

You see a scary error like this staring back at you:

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

Yeah, that’s the dreaded OpenSSL Error 0308010C. Don’t panic! It’s common, and there are easy fixes.

This error started popping up more after Node.js 17+ versions were released. Luckily, you’re not the first one to encounter it. Let’s break down 💥what’s going on, why it happens, and exactly how to fix it.

🔍 What’s Causing the Problem?

This error is due to how Node.js, Webpack, and OpenSSL interact. Node.js 17 and newer switched from using OpenSSL 1.1.1 to OpenSSL 3.0.

The crypto behavior in OpenSSL 3.0 is more secure, but it’s also stricter. If you’re using Webpack (especially an older version), it may rely on now-unsupported algorithms. That’s why you get:

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

Translation: Your build tools tried to do something crypto-related, and OpenSSL said “Nope, that’s not allowed anymore.”

🚑 Fixing the Error — Your Toolbox

Let’s go through some simple ways to fix this issue.

👉 Option 1: Use Node 16

The fastest fix? Switch to Node.js 16, where this error doesn’t pop up as easily.

Here’s how:

  1. If you’re using nvm (Node Version Manager):
  2. nvm install 16
    nvm use 16
  3. Or if you’re not using nvm, install Node 16 from the official site: nodejs.org

Why it works: Node 16 still uses OpenSSL 1.1.1, which is more lenient. It won’t give you random crypto errors during builds.

👉 Option 2: Set an Environment Variable

If you’re on Node.js 17 or 18 and you don’t want to downgrade, try this workaround.

Before running your build or dev server, set this environment variable:

export NODE_OPTIONS=--openssl-legacy-provider

Or on Windows (PowerShell):

$env:NODE_OPTIONS="--openssl-legacy-provider"

Then run:

npm run build

This tells Node to let older crypto algorithms pass through. It’s like giving it a “get out of jail free” card.

👉 Option 3: Update Webpack

If your project is using an older version of Webpack (especially v4), that could be the real problem.

Webpack 5 is better adapted to work with the newer Node.js and OpenSSL versions.

Update Webpack with:

npm install webpack@latest --save-dev

And if you’re on Next.js, make sure it’s on a version that supports Webpack 5+.

Note: If you’re using other packages that rely on Webpack, update them too.

⚙️ Bonus: How to Check What Versions You’re Using

Wondering what Node.js version you’re using? Run:

node -v

To check your Webpack version:

npx webpack --version

And for Next.js:

npm list next

🤖 If You’re Using a CI/CD Pipeline

Sometimes this error appears only during builds in platforms like:

If this happens, you can either:

For example, in GitHub Actions:

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/setup-node@v3
        with:
          node-version: 16

And for Vercel, just open your project settings and set:


NODE_OPTIONS = --openssl-legacy-provider

Or switch the Node version from the Environment tab.

🧼 Recap: Your Fix Checklist

Quick summary of your toolkit:

Pick the fix that works best for your setup. You don’t need to use all of them.

😂 Fun Developer Tip

When you see this error, just whisper to yourself:

“It’s not me. It’s OpenSSL.” 🎭

Even experts still get tripped up by these things. So don’t feel bad. Just fix it, laugh a little… then chug another coffee and keep coding!

🎉 You’re All Set!

No more cryptic OpenSSL errors. Next time Webpack throws a tantrum, you’ll be ready with your ninja tools. 💻🕶️

Happy building!

Follow Us
Exit mobile version