【开发日记】Error: error:0308010C:digital envelope routines::unsupported

异常:

node:internal/crypto/hash:71
  this[kHandle] = new _Hash(algorithm, xofLen);
                  ^

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

原因:

使用Node v18启动Node v14创建的项目出现如上异常

解决:

package.json中调整scripts,如下
原:

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

调整:

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

注意:

调整后,node v14会报错

其他解决方法:

设置环境变量,自行百度

你可能感兴趣的:(Vue,Web错误集锦,vue.js,javascript,前端)