出現Error: error:0308010C:digital envelope routines::unsupported - 解決方法
如果你遇到 Error: error:0308010C:digital envelope routines::unsupported ,而具體Error Stack是:
{
opensslErrorStack: [ 'error:03000086:digital envelope routines::initialization error' ],
library: 'digital envelope routines',
reason: 'unsupported',
code: 'ERR_OSSL_EVP_UNSUPPORTED'
}
請檢查一下你的node版本:
node -v
相信版本應該是 v17 以上,因為node.js公佈了以下更新:
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. A new command-line option,--openssl-legacy-provider
, has been added to revert to the legacy provider as a temporary workaround for these tightened restrictions.
解決ERR_OOSSL_EVP_UNSUPPORTED error code的方法
正如node.js的文章所說,快速臨時方法,是加上parameter --openssl-legacy-provider ,以下script是假設你正在修改package.json內的scripts部分:
# 原來的指令
"scripts": {
"dev": "gatsby develop"
}
# 上新定義的變數
"scripts": {
"dev": "export NODE_OPTIONS=--openssl-legacy-provider;gatsby develop"
}
或者把node 降到v17以下
sudo n 16