How to fix Failed to load config from vite.config.ts: error:0308010C:digital envelope routines::unsupported in React
This cryptographic error occurs when using Node.js v17+ with Vite, caused by OpenSSL 3.0 dropping support for legacy hash algorithms like MD4 that older build tools depend on.
Quick fix
Fixes ERR_OSSL_EVP_UNSUPPORTED
export NODE_OPTIONS=--openssl-legacy-provider
npm run dev- Enable OpenSSL legacy provider (Quick fix)
- Update Node.js to LTS version with latest patches
- Update Vite and build dependencies
- Verify Vite configuration format
export NODE_OPTIONS=--openssl-legacy-providernpm run devFailed to load config from vite.config.ts: error:0308010C:digital envelope routines::unsupported
What this error means
This error appears when Vite attempts to load its configuration file but encounters a cryptographic operation that's no longer supported in modern Node.js versions. Starting with Node.js v17, the runtime switched to OpenSSL 3.0, which removed several legacy cryptographic algorithms including MD4 hashing. The error code "0308010C" specifically indicates that a digital envelope routine (used for encryption/decryption operations) attempted to use an unsupported algorithm. Vite's dependency chain—particularly older versions of webpack or esbuild—may rely on these legacy algorithms for generating build hashes and other cryptographic operations. This is fundamentally a Node.js compatibility issue rather than a Vite bug. The error surfaces during config loading because that's when Vite first invokes these cryptographic operations to process and bundle your configuration file.
Typical symptoms
- Build fails immediately when running "npm run dev" or "vite"
- Error message contains "error:0308010C:digital envelope routines"
- Error occurs after upgrading Node.js to v17 or later
- Previously working Vite projects suddenly fail to start
- Stack trace points to vite.config.ts or vite.config.js loading
- Development server never starts, fails during initialization
Common causes
- Using Node.js v17 or later with OpenSSL 3.0 that removed MD4 algorithm support
- Outdated build dependencies (webpack, esbuild) that rely on legacy crypto algorithms
- Project was created with older tooling and hasn't been updated for Node.js v17+ compatibility
- Environment variables or build scripts don't account for OpenSSL changes
- Vite configuration uses plugins with outdated cryptographic dependencies
How to fix "Failed to load config from vite.config.ts: error:0308010C:digital envelope routines::unsupported"
Set the NODE_OPTIONS environment variable to use the legacy OpenSSL provider:
Linux/macOS:
export NODE_OPTIONS=--openssl-legacy-provider
npm run devWindows (Command Prompt):
set NODE_OPTIONS=--openssl-legacy-provider
npm run devWindows (PowerShell):
$env:NODE_OPTIONS="--openssl-legacy-provider"
npm run devPermanent solution in package.json:
{
"scripts": {
"dev": "NODE_OPTIONS=--openssl-legacy-provider vite",
"build": "NODE_OPTIONS=--openssl-legacy-provider vite build"
}
}For cross-platform compatibility, use the cross-env package:
npm install --save-dev cross-env{
"scripts": {
"dev": "cross-env NODE_OPTIONS=--openssl-legacy-provider vite",
"build": "cross-env NODE_OPTIONS=--openssl-legacy-provider vite build"
}
}This re-enables the legacy algorithms that were removed in OpenSSL 3.0.
If you're on Node.js v17 or v18, upgrade to the latest LTS version (Node.js 20+):
# Check current version
node --version
# Using nvm (recommended)
nvm install --lts
nvm use --lts
# Or download from nodejs.org
# https://nodejs.org/Newer Node.js versions include better compatibility handling and updated build tools have adapted to OpenSSL 3.0 changes.
After upgrading, clean install dependencies:
rm -rf node_modules package-lock.json
npm installUpgrade Vite and related build tools to versions that support Node.js v17+:
# Update Vite to latest version
npm install vite@latest --save-dev
# Update all build-related dependencies
npm update esbuild webpack @vitejs/plugin-reactCheck your package.json for minimum recommended versions:
- Vite 3.0.0+ (better yet, 4.0.0+)
- esbuild 0.15.0+
- webpack 5.0.0+ (if used)
After updating:
rm -rf node_modules package-lock.json
npm install
npm run devEnsure your vite.config.ts uses proper ESM syntax and TypeScript configuration:
// vite.config.ts
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
export default defineConfig({
plugins: [react()],
});Check package.json has proper module configuration:
{
"type": "module"
}If not using "type": "module", rename to vite.config.mts:
mv vite.config.ts vite.config.mtsThe .mts extension explicitly marks the file as an ES module.
If you need an immediate fix and can't update dependencies, downgrade to Node.js v16:
# Using nvm
nvm install 16
nvm use 16
# Verify version
node --version # Should show v16.x.x
# Clean install
rm -rf node_modules package-lock.json
npm installWarning: Node.js v16 reached end-of-life in September 2023. This is only a temporary solution while you plan to update your dependencies. Do not use this approach for production deployments.
Advanced notes
Understanding OpenSSL 3.0 Changes:
Node.js v17 introduced OpenSSL 3.0, which removed several legacy cryptographic algorithms deemed insecure, including MD4, MD5 (in some contexts), and others. This was a security-focused decision, but it broke backward compatibility with build tools that relied on these algorithms for non-security-critical operations like generating content hashes.
Why --openssl-legacy-provider works:
This flag tells Node.js to load the legacy provider from OpenSSL 3.0, which includes the removed algorithms. While this sounds concerning from a security perspective, these algorithms are only used for build-time operations (file hashing, cache keys) and not for actual cryptographic security in your application. Your production code's security is unaffected.
Production considerations:
If deploying to environments where you control the Node.js version (Docker, serverless functions), ensure your package.json specifies an engine requirement:
{
"engines": {
"node": ">=20.0.0"
}
}Alternative: Use a different bundler:
If Vite continues causing issues, consider alternatives like Turbopack, Rspack, or updating to frameworks with built-in bundlers (Next.js 13+, Remix) that handle these compatibility issues transparently.
CI/CD pipelines:
In GitHub Actions, specify Node.js version explicitly:
- uses: actions/setup-node@v4
with:
node-version: '20'For Docker builds:
FROM node:20-alpine
ENV NODE_OPTIONS=--openssl-legacy-providerFrequently asked questions
- What does "ERR_OSSL_EVP_UNSUPPORTED" mean?
- js versions. 0, which removed several legacy cryptographic algorithms including MD4 hashing. The error code "0308010C" specifically indicates that a digital envelope routine (used for encryption/decryption operations) attempted to use an unsupported algorithm.
- How do I fix "ERR_OSSL_EVP_UNSUPPORTED"?
- This cryptographic error occurs when using Node.js v17+ with Vite, caused by OpenSSL 3.0 dropping support for legacy hash algorithms like MD4 that older build tools depend on.
- What causes "ERR_OSSL_EVP_UNSUPPORTED"?
- Using Node.js v17 or later with OpenSSL 3.0 that removed MD4 algorithm support Outdated build dependencies (webpack, esbuild) that rely on legacy crypto algorithms Project was created with older tooling and hasn't been updated for Node.js v17+ compatibility
- Is the "ERR_OSSL_EVP_UNSUPPORTED" error serious?
- Yes. This is a high-severity error that usually blocks work until it is fixed, but the steps above resolve it.
Official resources & further reading
- 📚React Official Documentation
- 📖Vite Official Guide - Installation & Requirements(Official Docs)
- 📖Node.js Official Documentation(Official Docs)
- 🐙
- 📖React Official Documentation - Getting Started(Official Docs)