node.js升级报错digital envelope routines unsupporte最简单解决方案

背景:本地将nodejs 16升级成nodejs18运行时报错digital envelope routines::unsupported

报错

Error: error:0308010C:digital envelope routines::unsupported
    at new Hash (node:internal/crypto/hash:71:19)
    at Object.createHash (node:crypto:133:10)

源代码


"scripts": {
    "dev": "vue-cli-service serve",
    "build": "vue-cli-service build",
}

替换为

"scripts": {
    "dev": "SET NODE_OPTIONS=--openssl-legacy-provider && vue-cli-service serve",
    "build": "SET NODE_OPTIONS=--openssl-legacy-provider && vue-cli-service build" , 
}

重新执行npm run dev即可

你可能感兴趣的:(vue,node.js,vue.js,javascript)