error:03000086:digital envelope routines::initialization error 问题解决

慕雪是在使用vuepress的时候遇到了这个错误。根据官方的描述,vuepress应该使用node.js 14版本即可,但我的电脑上是18.x

完整报错如下

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
PS D:\Git_repo\hexo\khl.py.docs> npm run docs:dev 

> docs:dev
> vuepress dev docs

wait Extracting site metadata...
tip Apply theme @vuepress/theme-default ...
tip Apply plugin container (i.e. "vuepress-plugin-container") ...
tip Apply plugin @vuepress/register-components (i.e. "@vuepress/plugin-register-components") ...
tip Apply plugin @vuepress/active-header-links (i.e. "@vuepress/plugin-active-header-links") ...
tip Apply plugin @vuepress/search (i.e. "@vuepress/plugin-search") ...
tip Apply plugin @vuepress/nprogress (i.e. "@vuepress/plugin-nprogress") ...

* Client █████████████████████████ building (40%) 1/2 modules 1 active
node_modules\webpack-dev-server\client\index.js

i 「wds」: Project is running at http://0.0.0.0:8081/
i 「wds」: webpack output is served from /
i 「wds」: Content not from webpack is served from D:\Git_repo\hexo\khl.py.docs\docs\.vuepress\public
i 「wds」: 404s will fallback to /index.html
node:internal/crypto/hash:71
this[kHandle] = new _Hash(algorithm, xofLen);
^

Error: error:0308010C:digital envelope routines::unsupported
at new Hash (node:internal/crypto/hash:71:19)
at Object.createHash (node:crypto:133:10)
at module.exports (D:\Git_repo\HEXO\khl.py.docs\node_modules\webpack\lib\util\createHash.js:135:53)
at NormalModule._initBuildHash (D:\Git_repo\HEXO\khl.py.docs\node_modules\webpack\lib\NormalModule.js:417:16)
at handleParseError (D:\Git_repo\HEXO\khl.py.docs\node_modules\webpack\lib\NormalModule.js:471:10)
at D:\Git_repo\HEXO\khl.py.docs\node_modules\webpack\lib\NormalModule.js:503:5
at D:\Git_repo\HEXO\khl.py.docs\node_modules\webpack\lib\NormalModule.js:358:12
at D:\Git_repo\HEXO\khl.py.docs\node_modules\loader-runner\lib\LoaderRunner.js:373:3
at iterateNormalLoaders (D:\Git_repo\HEXO\khl.py.docs\node_modules\loader-runner\lib\LoaderRunner.js:214:10)
at Array.<anonymous> (D:\Git_repo\HEXO\khl.py.docs\node_modules\loader-runner\lib\LoaderRunner.js:205:4)
at Storage.finished (D:\Git_repo\HEXO\khl.py.docs\node_modules\enhanced-resolve\lib\CachedInputFileSystem.js:55:16)
at D:\Git_repo\HEXO\khl.py.docs\node_modules\enhanced-resolve\lib\CachedInputFileSystem.js:91:9
at D:\Git_repo\HEXO\khl.py.docs\node_modules\graceful-fs\graceful-fs.js:123:16
at FSReqCallback.readFileAfterClose [as oncomplete] (node:internal/fs/read_file_context:68:3) {
opensslErrorStack: [ 'error:03000086:digital envelope routines::initialization error' ],
library: 'digital envelope routines',
reason: 'unsupported',
code: 'ERR_OSSL_EVP_UNSUPPORTED'
}

Node.js v18.15.0

使用原文中的方法3,成功解决此问题


以下为原文

1
2
版权声明:本文为CSDN博主「忙碌的菠萝」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/qq_21271511/article/details/127996193

问题描述

问题背景

更换新机器的时候下载使用了最新版的nodejs,部署老项目的时候启动报错了

错误描述

跑了一下ruoyi的项目试试,就直接给报了 Error: error:0308010C:digital envelope routines::unsupported

Error: error:0308010C:digital envelope routines::unsupported
    at new Hash (node:internal/crypto/hash:71:19)
    at Object.createHash (node:crypto:133:10)
    at module.exports (D:\dev\workspace\RuoYi-Vue-master\ruoyi-ui\node_modules\webpack\lib\util\createHash.js:135:53)
    at NormalModule._initBuildHash (D:\dev\workspace\RuoYi-Vue-master\ruoyi-ui\node_modules\webpack\lib\NormalModule.js:417:16)
    at handleParseError (D:\dev\workspace\RuoYi-Vue-master\ruoyi-ui\node_modules\webpack\lib\NormalModule.js:471:10)
    at D:\dev\workspace\RuoYi-Vue-master\ruoyi-ui\node_modules\webpack\lib\NormalModule.js:503:5
    at D:\dev\workspace\RuoYi-Vue-master\ruoyi-ui\node_modules\webpack\lib\NormalModule.js:358:12
    at D:\dev\workspace\RuoYi-Vue-master\ruoyi-ui\node_modules\loader-runner\lib\LoaderRunner.js:373:3
    at iterateNormalLoaders (D:\dev\workspace\RuoYi-Vue-master\ruoyi-ui\node_modules\loader-runner\lib\LoaderRunner.js:214:10)
    at Array.<anonymous> (D:\dev\workspace\RuoYi-Vue-master\ruoyi-ui\node_modules\loader-runner\lib\LoaderRunner.js:205:4)
    at D:\dev\workspace\RuoYi-Vue-master\ruoyi-ui\node_modules\graceful-fs\graceful-fs.js:123:16
    at FSReqCallback.readFileAfterClose [as oncomplete] (node:internal/fs/read_file_context:68:3) {
  opensslErrorStack: [ 'error:03000086:digital envelope routines::initialization error' ],
  library: 'digital envelope routines',
  reason: 'unsupported',
  code: 'ERR_OSSL_EVP_UNSUPPORTED'

问题解决

原因分析

1、原项目是在nodejs 16版本上跑,目前升级为nodejs 18,可能是由于升级影响的
2、具体错误原因:ERR_OSSL_EVP_UNSUPPORTED 错误SSL 数字信封不支持

解决措施

1、set NODE_OPTIONS=--openssl-legacy-provider

这个亲测并没有什么软用

PS D:\dev\workspace\RuoYi-Vue-master\ruoyi-ui> set NODE_OPTIONS=--openssl-legacy-provider
PS D:\dev\workspace\RuoYi-Vue-master\ruoyi-ui> npm run dev

> ruoyi@3.8.4 dev
> vue-cli-service serve

 INFO  Starting development server...
10% building 2/2 modules 0 activeError: error:0308010C:digital envelope routines::unsupported

2、降级nodejs

升级再降级也没有道理,虽然也是可以的,最后总是要升级的,不推荐

1
2
3
nvm ls available

nvm install 16.13.0

或者卸载当前的nodejs 重新下载安装即可

3、修改环境变量问题解决

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

输出如下

1
2
3
4
5
6
7
8
9
10
11
PS D:\dev\workspace\RuoYi-Vue-master\ruoyi-ui> $env:NODE_OPTIONS="--openssl-legacy-provider" 
PS D:\dev\workspace\RuoYi-Vue-master\ruoyi-ui> npm run dev

> ruoyi@3.8.4 dev
> vue-cli-service serve

INFO Starting development server...
98% after emitting CopyPlugin

DONE Compiled successfully in 18898ms