问题描述:
报错:Error: error:0308010C:digital envelope routines::unsupported
报错原因:
主要是因为 nodeJs V17 版本发布了 OpenSSL3.0 对算法和密钥大小增加了更为严格的限制,nodeJs v17 之前版本没影响,但 V17 和之后版本会出现这个错误。
解决方案:
方案1:打开IDEA终端,直接输入
Linux & Mac OS:
| 1 | export NODE_OPTIONS=--openssl-legacy-provider |
|---|
Windows:
| 1 | set NODE_OPTIONS=--openssl-legacy-provider |
|---|
方案2:打开IDEA终端,直接输入(问题解决)
| 1 | $env:NODE_OPTIONS="--openssl-legacy-provider" |
|---|
方案3:卸载Node.js17+版本,安装Node.js17-版本(一劳永逸,可以自行尝试)
方案4:package.json增加配置(我使用这个了)
在项目中 package.json 的 scripts 中新增 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"
},