npm run serve报错:error:0308010C:digital envelope routines::unsupported

这是因为Node.js17+中的OpenSSL加密库不支持当前的加密设置。

因为新版本默认使用OpenSSL 3,它可能不再支持旧版的加密算法或配置。

> demo@0.1.0 serve
> vue-cli-service serve

 INFO  Starting development server...
10% building 2/5 modules 3 active ...\vue\node_modules\babel-loader\lib\index.js!E:\xianyu\dormitory_manager_system\vue\src\main.jsE
rror: error:0308010C:digital envelope routines::unsupported
    at new Hash (node:internal/crypto/hash:69:19)
    at Object.createHash (node:crypto:133:10)
    at module.exports (E:\xianyu\dormitory_manager_system\vue\node_modules\webpack\lib\util\createHash.js:135:53)
    at NormalModule._initBuildHash (E:\xianyu\dormitory_manager_system\vue\node_modules\webpack\lib\NormalModule.js:417:16)
    at handleParseError (E:\xianyu\dormitory_manager_system\vue\node_modules\webpack\lib\NormalModule.js:471:10)
    at E:\xianyu\dormitory_manager_system\vue\node_modules\webpack\lib\NormalModule.js:503:5
    at E:\xianyu\dormitory_manager_system\vue\node_modules\webpack\lib\NormalModule.js:358:12
    at E:\xianyu\dormitory_manager_system\vue\node_modules\loader-runner\lib\LoaderRunner.js:373:3
    at iterateNormalLoaders (E:\xianyu\dormitory_manager_system\vue\node_modules\loader-runner\lib\LoaderRunner.js:214:10)
    at iterateNormalLoaders (E:\xianyu\dormitory_manager_system\vue\node_modules\loader-runner\lib\LoaderRunner.js:221:10)
    at E:\xianyu\dormitory_manager_system\vue\node_modules\loader-runner\lib\LoaderRunner.js:236:3
    at runSyncOrAsync (E:\xianyu\dormitory_manager_system\vue\node_modules\loader-runner\lib\LoaderRunner.js:130:11)
    at iterateNormalLoaders (E:\xianyu\dormitory_manager_system\vue\node_modules\loader-runner\lib\LoaderRunner.js:232:2)
    at Array.<anonymous> (E:\xianyu\dormitory_manager_system\vue\node_modules\loader-runner\lib\LoaderRunner.js:205:4)
    at Storage.finished (E:\xianyu\dormitory_manager_system\vue\node_modules\enhanced-resolve\lib\CachedInputFileSystem.js:55:16)
    at E:\xianyu\dormitory_manager_system\vue\node_modules\enhanced-resolve\lib\CachedInputFileSystem.js:91:9
node:internal/crypto/hash:69
  this[kHandle] = new _Hash(algorithm, xofLen);
                  ^

Error: error:0308010C:digital envelope routines::unsupported
    at new Hash (node:internal/crypto/hash:69:19)
    at Object.createHash (node:crypto:133:10)
    at module.exports (E:\xianyu\dormitory_manager_system\vue\node_modules\webpack\lib\util\createHash.js:135:53)
    at NormalModule._initBuildHash (E:\xianyu\dormitory_manager_system\vue\node_modules\webpack\lib\NormalModule.js:417:16)
    at handleParseError (E:\xianyu\dormitory_manager_system\vue\node_modules\webpack\lib\NormalModule.js:471:10)
    at E:\xianyu\dormitory_manager_system\vue\node_modules\webpack\lib\NormalModule.js:503:5
    at E:\xianyu\dormitory_manager_system\vue\node_modules\webpack\lib\NormalModule.js:358:12
    at E:\xianyu\dormitory_manager_system\vue\node_modules\loader-runner\lib\LoaderRunner.js:373:3
    at iterateNormalLoaders (E:\xianyu\dormitory_manager_system\vue\node_modules\loader-runner\lib\LoaderRunner.js:214:10)
    at Array.<anonymous> (E:\xianyu\dormitory_manager_system\vue\node_modules\loader-runner\lib\LoaderRunner.js:205:4)
    at Storage.finished (E:\xianyu\dormitory_manager_system\vue\node_modules\enhanced-resolve\lib\CachedInputFileSystem.js:55:16)
    at E:\xianyu\dormitory_manager_system\vue\node_modules\enhanced-resolve\lib\CachedInputFileSystem.js:91:9
    at E:\xianyu\dormitory_manager_system\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.17.1

如果你和我一样不想升级项目中的依赖,也不想降低node.js的版本,只需要设置环境变量 NODE_OPTIONS 来指定使用OpenSSL的遗留提供者(legacy provider),在控制台输入 ,再运行就OK

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

 

  • 8
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值