启动vue项目时报错digital envelope routines__unsupported
今天把node.js升级到了最新版v18.15.0,启动以前的vue项目时报错:
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:\home\project\demo\vue-admin-better\node_modules\webpack\lib\util\createHash.js:135:53)
at NormalModule._initBuildHash (D:\home\project\demo\vue-admin-better\node_modules\webpack\lib\NormalModule.js:417:16)
at handleParseError (D:\home\project\demo\vue-admin-better\node_modules\webpack\lib\NormalModule.js:471:10)
at D:\home\project\demo\vue-admin-better\node_modules\webpack\lib\NormalModule.js:503:5
at D:\home\project\demo\vue-admin-better\node_modules\webpack\lib\NormalModule.js:358:12
at D:\home\project\demo\vue-admin-better\node_modules\loader-runner\lib\LoaderRunner.js:373:3
at iterateNormalLoaders (D:\home\project\demo\vue-admin-better\node_modules\loader-runner\lib\LoaderRunner.js:214:10)
at iterateNormalLoaders (D:\home\project\demo\vue-admin-better\node_modules\loader-runner\lib\LoaderRunner.js:221:10)
at D:\home\project\demo\vue-admin-better\node_modules\loader-runner\lib\LoaderRunner.js:236:3
at runSyncOrAsync (D:\home\project\demo\vue-admin-better\node_modules\loader-runner\lib\LoaderRunner.js:130:11)
at iterateNormalLoaders (D:\home\project\demo\vue-admin-better\node_modules\loader-runner\lib\LoaderRunner.js:232:2)
at Array.<anonymous> (D:\home\project\demo\vue-admin-better\node_modules\loader-runner\lib\LoaderRunner.js:205:4)
at Storage.finished (D:\home\project\demo\vue-admin-better\node_modules\enhanced-resolve\lib\CachedInputFileSystem.js:55:16)
at D:\home\project\demo\vue-admin-better\node_modules\enhanced-resolve\lib\CachedInputFileSystem.js:91:9
10% building 2/5 modules 3 active ...dmin-better\node_modules\eslint-loader\index.js??ref--14-0!D:\home\project\demo\vue-admin-better\src\main.jsnode: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:\home\project\demo\vue-admin-better\node_modules\webpack\lib\util\createHash.js:135:53)
at NormalModule._initBuildHash (D:\home\project\demo\vue-admin-better\node_modules\webpack\lib\NormalModule.js:417:16)
at handleParseError (D:\home\project\demo\vue-admin-better\node_modules\webpack\lib\NormalModule.js:471:10)
at D:\home\project\demo\vue-admin-better\node_modules\webpack\lib\NormalModule.js:503:5
at D:\home\project\demo\vue-admin-better\node_modules\webpack\lib\NormalModule.js:358:12
at D:\home\project\demo\vue-admin-better\node_modules\loader-runner\lib\LoaderRunner.js:373:3
at iterateNormalLoaders (D:\home\project\demo\vue-admin-better\node_modules\loader-runner\lib\LoaderRunner.js:214:10)
at Array.<anonymous> (D:\home\project\demo\vue-admin-better\node_modules\loader-runner\lib\LoaderRunner.js:205:4)
at Storage.finished (D:\home\project\demo\vue-admin-better\node_modules\enhanced-resolve\lib\CachedInputFileSystem.js:55:16)
at D:\home\project\demo\vue-admin-better\node_modules\enhanced-resolve\lib\CachedInputFileSystem.js:91:9
at D:\home\project\demo\vue-admin-better\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
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
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
在网上查询了解决方法,记录下。由于node.js
的版本问题,node.js V17
版本中最近发布的OpenSSL3.0
, 而OpenSSL3.0
对允许算法和密钥大小增加了严格的限制,可能会对生态系统造成一些影响。故此以前的项目在升级 nodejs
版本后会报错。
解决方法
修改package.json
,在相关构建命令之前加入set NODE_OPTIONS=–openssl-legacy-provider
"scripts": {
"dev": "SET NODE_OPTIONS=--openssl-legacy-provider && vue-cli-service serve",
"build": "SET NODE_OPTIONS=--openssl-legacy-provider && vue-cli-service build"
}
1
2
3
4
2
3
4
如果是 Linux
或者 WSL
环境,请加入
export NODE_OPTIONS=--openssl-legacy-provider
1
如果是windows
,我的电脑上右键–>属性—>环境变量->系统变量->新建->高级系统设置
保存后
windows
需要重启一下电脑,然后就可以运行npm
打包命令不会报错了
上次更新: 2024/02/20, 17:31:36
- 01
- Node与GLIBC_2.27不兼容解决方案08-19
- 02
- Git清空本地文件跟踪缓存08-13