出现这个错误是因为 node.js V17版本中最近发布的OpenSSL3.0, 而OpenSSL3.0对允许算法和密钥大小增加了严格的限制,可能会对生态系统造成一些影响.
方法1:运行前$ npm run serve前 先运行
export NODE_OPTIONS=--openssl-legacy-provider
方法2,将以上命令写入package.json文件
"scripts": {"serve": "SET NODE_OPTIONS=--openssl-legacy-provider && vue-cli-service serve","build": "SET NODE_OPTIONS=--openssl-legacy-provider && vue-cli-service build" },
方法3,降低版本至v16
请参考:Vue 报错error:0308010C:digital envelope routines::unsupported_柠檬果子青的博客-CSDN博客