npm Failed to construct transformer Error error:0308010C:digital envelope

Failed to construct transformer: Error: error:0308010C:digital envelope routines::unsupported

➜  PluginReact git:(master) ✗ npm start -- --reset-cache

> start
> react-native start --reset-cache


#######
################
######### #########
######### ##########
######### ###### #########
##########################################
##### ##################### #####
##### ############## #####
##### ### ###### ### #####
##### ####### ####### #####
##### ########### ########### #####
##### ########################## #####
##### ########################## #####
##### ###################### ######
###### ############# #######
######### #### #########
######### #########
######### #########
#########


warning: the transform cache was reset.
Welcome to Metro!
Fast - Scalable - Integrated



To reload the app press "r"
To open developer menu press "d"

Failed to construct transformer: Error: error:0308010C:digital envelope routines::unsupported
at new Hash (node:internal/crypto/hash:79:19)
at Object.createHash (node:crypto:139:10)
at stableHash (/Users/mac/.../PluginReact/node_modules/metro-cache/src/stableHash.js:19:8)
at Object.getCacheKey (/Users/mac/.../PluginReact/node_modules/metro-transform-worker/src/index.js:593:7)
at getTransformCacheKey (/Users/mac/.../PluginReact/node_modules/metro/src/DeltaBundler/getTransformCacheKey.js:24:19)
at new Transformer (/Users/mac/.../PluginReact/node_modules/metro/src/DeltaBundler/Transformer.js:48:9)
at /Users/mac/.../PluginReact/node_modules/metro/src/Bundler.js:22:29 {
opensslErrorStack: [
'error:03000086:digital envelope routines::initialization error',
'error:0308010C:digital envelope routines::unsupported'
],
library: 'digital envelope routines',
reason: 'unsupported',
code: 'ERR_OSSL_EVP_UNSUPPORTED'
}

这个报错其实是Node.js版本和OpenSSL默认配置不兼容导致的,常见在Node 17+或者Node 18下跑React Native / Metro bundler的时候。

这是因为Node.jsv17开始启用了新的OpenSSL 3.0,老代码里用的createHash('md4')md5等算法默认被禁用了。

解决方法,加环境变量:

export NODE_OPTIONS=--openssl-legacy-provider

npm Failed to construct transformer Error error:0308010C:digital envelope

https://cctv3.net/static/20250928/npm-digital-envelope-routines-unsupported.html

作者

陈桥驿站

发布于

2025-09-28

更新于

2025-09-28

许可协议

评论