IT俱乐部 JavaScript nodejs报digital envelope routines::unsupported错误的最新解决方法

nodejs报digital envelope routines::unsupported错误的最新解决方法

这两天准备在github上找一个vue3的后台框架学习一下,后来找到一个vue-admin-better这个VUE3开发后台框架,感觉不错,准备安装了跑起来看一看效果

就运行

npm run serve

结果就报一堆错误

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:homeprojectdemovue-admin-betternode_moduleswebpacklibutilcreateHash.js:135:53)
    at NormalModule._initBuildHash (D:homeprojectdemovue-admin-betternode_moduleswebpacklibNormalModule.js:417:16)
    at handleParseError (D:homeprojectdemovue-admin-betternode_moduleswebpacklibNormalModule.js:471:10)
    at D:homeprojectdemovue-admin-betternode_moduleswebpacklibNormalModule.js:503:5
    at D:homeprojectdemovue-admin-betternode_moduleswebpacklibNormalModule.js:358:12
    at D:homeprojectdemovue-admin-betternode_modulesloader-runnerlibLoaderRunner.js:373:3
    at iterateNormalLoaders (D:homeprojectdemovue-admin-betternode_modulesloader-runnerlibLoaderRunner.js:214:10)
    at iterateNormalLoaders (D:homeprojectdemovue-admin-betternode_modulesloader-runnerlibLoaderRunner.js:221:10)
    at D:homeprojectdemovue-admin-betternode_modulesloader-runnerlibLoaderRunner.js:236:3
    at runSyncOrAsync (D:homeprojectdemovue-admin-betternode_modulesloader-runnerlibLoaderRunner.js:130:11)
    at iterateNormalLoaders (D:homeprojectdemovue-admin-betternode_modulesloader-runnerlibLoaderRunner.js:232:2)
    at Array. (D:homeprojectdemovue-admin-betternode_modulesloader-runnerlibLoaderRunner.js:205:4)
    at Storage.finished (D:homeprojectdemovue-admin-betternode_modulesenhanced-resolvelibCachedInputFileSystem.js:55:16)
    at D:homeprojectdemovue-admin-betternode_modulesenhanced-resolvelibCachedInputFileSystem.js:91:9
10% building 2/5 modules 3 active …dmin-betternode_moduleseslint-loaderindex.js??ref–14-0!D:homeprojectdemovue-admin-bettersrcmain.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:homeprojectdemovue-admin-betternode_moduleswebpacklibutilcreateHash.js:135:53)
    at NormalModule._initBuildHash (D:homeprojectdemovue-admin-betternode_moduleswebpacklibNormalModule.js:417:16)
    at handleParseError (D:homeprojectdemovue-admin-betternode_moduleswebpacklibNormalModule.js:471:10)
    at D:homeprojectdemovue-admin-betternode_moduleswebpacklibNormalModule.js:503:5
    at D:homeprojectdemovue-admin-betternode_moduleswebpacklibNormalModule.js:358:12
    at D:homeprojectdemovue-admin-betternode_modulesloader-runnerlibLoaderRunner.js:373:3
    at iterateNormalLoaders (D:homeprojectdemovue-admin-betternode_modulesloader-runnerlibLoaderRunner.js:214:10)
    at Array. (D:homeprojectdemovue-admin-betternode_modulesloader-runnerlibLoaderRunner.js:205:4)
    at Storage.finished (D:homeprojectdemovue-admin-betternode_modulesenhanced-resolvelibCachedInputFileSystem.js:55:16)
    at D:homeprojectdemovue-admin-betternode_modulesenhanced-resolvelibCachedInputFileSystem.js:91:9
    at D:homeprojectdemovue-admin-betternode_modulesgraceful-fsgraceful-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’
}

Baidu 了一下发现是 Node JS 17 的 BUG,相关 ISSUE 也给出了解决办法,就是修改package.json,在相关构建命令之前加入set NODE_OPTIONS=–openssl-legacy-provider

"scripts": {
    "serve": "set NODE_OPTIONS=--openssl-legacy-provider & vue-cli-service serve",
    "build": "set NODE_OPTIONS=--openssl-legacy-provider & vue-cli-service build",
    "build:report": "set NODE_OPTIONS=--openssl-legacy-provider & vue-cli-service build --report",

如果是 Linux 或者 WSL 环境,请加入

export NODE_OPTIONS=--openssl-legacy-provider

如果是windows ,我的电脑上右键–>属性—>高级系统设置

保存后windows需要重启一下电脑

然后就可以运行npm打包命令不会报错了

到此这篇关于解决nodejs报digital envelope routines::unsupported错误的方法的文章就介绍到这了,更多相关nodejs报digital envelope routines::unsupported错误内容请搜索IT俱乐部以前的文章或继续浏览下面的相关文章希望大家以后多多支持IT俱乐部!

本文收集自网络,不代表IT俱乐部立场,转载请注明出处。https://www.2it.club/navsub/js/5882.html
上一篇
下一篇
联系我们

联系我们

在线咨询: QQ交谈

邮箱: 1120393934@qq.com

工作时间:周一至周五,9:00-17:30,节假日休息

关注微信
微信扫一扫关注我们

微信扫一扫关注我们

返回顶部