[Vue] [node.js] 报错:ERR_OSSL_EVP_UNSUPPORTED解决方法

现象

在Vue项目中,启动时报错ERR_OSSL_EVP_UNSUPPORTED。
具体报错内容:

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版本过高导致和以前的openssl版本不兼容。

解决方法

提供了两种解决方法,二选一。

1.设置环境变量

windows平台:
使用命令行输入如下命令:

set NODE_OPTIONS="--openssl-legacy-provider"

linux平台:
使用命令行输入如下命令:

export NODE_OPTIONs=--openssl-legacy-provider

2.修改Vue配置文件

在Vue的配置文件package.json中,在script中的serve和build命令中添加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",
    "lint": "vue-cli-service lint"
  },
  • 10
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值