main.jsError: error:0308010C:digital envelope routines::unsupported

旧版本node.js项目在新版本node.js环境启动失败,报错 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:\ideaWorkSpace\BG-XC\bg-xc-vue\node_modules\webpack\lib\util\createHash.js:135:53)
at NormalModule._initBuildHash (D:\ideaWorkSpace\BG-XC\bg-xc-vue\node_modules\webpack\lib\NormalModule.js:417:16)
at handleParseError (D:\ideaWorkSpace\BG-XC\bg-xc-vue\node_modules\webpack\lib\NormalModule.js:471:10)
at D:\ideaWorkSpace\BG-XC\bg-xc-vue\node_modules\webpack\lib\NormalModule.js:503:5
at D:\ideaWorkSpace\BG-XC\bg-xc-vue\node_modules\webpack\lib\NormalModule.js:358:12
at D:\ideaWorkSpace\BG-XC\bg-xc-vue\node_modules\loader-runner\lib\LoaderRunner.js:373:3
at iterateNormalLoaders (D:\ideaWorkSpace\BG-XC\bg-xc-vue\node_modules\loader-runner\lib\LoaderRunner.js:214:10)
at Array. (D:\ideaWorkSpace\BG-XC\bg-xc-vue\node_modules\loader-runner\lib\LoaderRunner.js:205:4)
at Storage.finished (D:\ideaWorkSpace\BG-XC\bg-xc-vue\node_modules\enhanced-resolve\lib\CachedInputFileSystem.js:55:16)
at D:\ideaWorkSpace\BG-XC\bg-xc-vue\node_modules\enhanced-resolve\lib\CachedInputFileSystem.js:91:9
at D:\ideaWorkSpace\BG-XC\bg-xc-vue\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.12.1

大概查了下网上的解决办法,具体如下:
1.通过cmd命令执行set NODE_OPTIONS=–openssl-legacy-provider(我本地无作用)
2.网上最多的答案,降低node.js版本。那么对于新的高版本的项目来说肯定不合适。

3.生效的方式:
在terminal中输入$env:NODE_OPTIONS="--openssl-legacy-provider" 之后再执行 npm run dev启动就可以了。

成功截图如下:
main.jsError: error:0308010C:digital envelope routines::unsupported_第1张图片

你可能感兴趣的:(vue,前台错误,vue.js,node.js)