如何修复 vue 中的“ERR_OSSL_EVP_UNSUPPORTED”错误?

곽동현*_*곽동현 16 node.js vue.js

opensslErrorStack: [ 'error:03000086:digital envelope routines::initialization error' ],
  library: 'digital envelope routines',
  reason: 'unsupported',
  code: 'ERR_OSSL_EVP_UNSUPPORTED'
}

Node.js v17.4.0
Run Code Online (Sandbox Code Playgroud)

执行npm run service时出现此错误。目前node是v16.14.0版本,不断重装还是重复同样的错误,因为这些错误在node v17中频繁出现。

"scripts": {
    "serve": "export NODE_OPTIONS=--openssl-legacy-provider && vue-cli-service serve",
    "build": "export NODE_OPTIONS=--openssl-legacy-provider && vue-cli-service build",
    "lint": "export NODE_OPTIONS=--openssl-legacy-provider && vue-cli-service lint"
},
Run Code Online (Sandbox Code Playgroud)

如果使用上面的代码是可以执行的,但是用docker构建镜像的时候又出现问题了。有解决办法吗?

小智 31

在 Windows 中,我可以使用以下方法解决此错误:

"scripts": {
    "serve": "set NODE_OPTIONS=--openssl-legacy-provider &&  vue-cli-service serve",
    ...
}
Run Code Online (Sandbox Code Playgroud)

  • OSX:`NODE_OPTIONS=--openssl-legacy-provider vue-cli-service 服务` (3认同)

小智 10

在省略导出中添加如下内容package.json,它将为我工作

"scripts": {
     "serve": "NODE_OPTIONS=--openssl-legacy-provider vue-cli-service serve",
},
Run Code Online (Sandbox Code Playgroud)