目录
- 1.故障现场
- 2. 问题分析
- 3. 修复方案
- 4. 参考文献
1.故障现场
最近由于一些原因,从Mac OSX 迁移到 Windows 平台,在尝试运行基于vue-element-admin 项目时,发生了如下异常:
error:0308010C:digital envelope routines::unsupported
at new Hash (node:internal/crypto/hash:67:19)
at Object.createHash (node:crypto:133:10)
at module.exports (F:\workspace\code\ui\xxx\node_modules\webpack\lib\util\createHash.js:135:53)
at NormalModule._initBuildHash (F:\workspace\code\ui\xxx\node_modules\webpack\lib\NormalModule.js:417:16)
at handleParseError (F:\workspace\code\ui\xxx\node_modules\webpack\lib\NormalModule.js:471:10)
at F:\workspace\code\ui\xxx\node_modules\webpack\lib\NormalModule.js:503:5
at F:\workspace\code\ui\xxx\node_modules\webpack\lib\NormalModule.js:358:12
at F:\workspace\code\ui\xxx\node_modules\loader-runner\lib\LoaderRunner.js:373:3
at iterateNormalLoaders (F:\workspace\code\ui\xxx\node_modules\loader-runner\lib\LoaderRunner.js:214:10)
at iterateNormalLoaders (F:\workspace\code\ui\xxx\node_modules\loader-runner\lib\LoaderRunner.js:221:10)
at F:\workspace\code\ui\xxx\node_modules\loader-runner\lib\LoaderRunner.js:236:3
at runSyncOrAsync (F:\workspace\code\ui\xxx\node_modules\loader-runner\lib\LoaderRunner.js:130:11)
at iterateNormalLoaders (F:\workspace\code\ui\xxx\node_modules\loader-runner\lib\LoaderRunner.js:232:2)
at Array.<anonymous> (F:\workspace\code\ui\xxx\node_modules\loader-runner\lib\LoaderRunner.js:205:4)
at Storage.finished (F:\workspace\code\ui\xxx\node_modules\enhanced-resolve\lib\CachedInputFileSystem.js:55:16)
at F:\workspace\code\ui\xxx\node_modules\enhanced-resolve\lib\CachedInputFileSystem.js:91:9
10% building 2/5 modules 3 active ...\lib\index.js!F:\workspace\code\ui\xxx\node_modules\eslint-loader\index.js??ref--13-0!F:\workspace\code\ui\xxx\src\main.js n
ode:internal/crypto/hash:67
this[kHandle] = n
2. 问题分析
同样的node版本和npm包,在Mac OSX 可以正常运行,而windows 上却不行?
经过一番排查和查找相关资料,都说要么降低node版本到16或以下,要么需要配置
export NODE_OPTIONS=--openssl-legacy-provider
我尝试后,还是不得行。
既然如此,那么会不会和openssl 有关呢?
于是,我查看了Mac OSX 上的openssl 版本。
openssl version -a
执行效果如下:
3. 修复方案
当时windows 安装的open ssl 版本是3.0.7.
后来尝试卸载后安装成了open ssl v1.1.1 后
编译构建成功,问题得以修复
4. 参考文献
- nodejs 17: digital envelope routines::unsupported #14532
- http://slproweb.com/products/Win32OpenSSL.html