报错信息如下:
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 .... 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 V17版本发布了OpenSSL3.0对算法和秘钥大小增加了更为严格的限制,node.js V17之前版本没影响,但V17和之后版本会出现这个错误。
解决办法:在package.json的scripts中新增SET NODE_OPTIONS=–openssl-legacy-provider
添加前: "scripts": { "dev": "vue-cli-service serve", "build:prod": "vue-cli-service build" }, 添加后 "scripts": { "dev": "SET NODE_OPTIONS=--openssl-legacy-provider && vue-cli-service serve", "build:prod": "SET NODE_OPTIONS=--openssl-legacy-provider && vue-cli-service build" },