Node v17以上版本运行旧项目报错 error:0308010C:digital envelope routines::unsupported

211 阅读1分钟

由于 Node.js v17 包含破坏性变更,添加了 OpenSSL 3.0,导致旧项目某些模块报错而启动失败。 解决方法这里有两个:

  • 使用Node.js v17以下的版本
  • 设置--openssl-legacy-provider

设置 --openssl-legacy-provider 的方法,比如在 windows 系统下项目启动命令修改为:

{
    "scripts": {
      "dev": "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"
    }
}

修改后再执行 npm run dev 就可以了。


Node v17.0.0 (Current)

Node v17.0.0 (Current)

OpenSSL 3.0

Node.js now includes OpenSSL 3.0, specifically quictls/openssl which provides QUIC support. With OpenSSL 3.0 FIPS support is again available using the new FIPS module. For details about how to build Node.js with FIPS support please see BUILDING.md.

While OpenSSL 3.0 APIs should be mostly compatible with those provided by OpenSSL 1.1.1, we do anticipate some ecosystem impact due to tightened restrictions on the allowed algorithms and key sizes.

If you hit an ERR_OSSL_EVP_UNSUPPORTED error in your application with Node.js 17, it’s likely that your application or a module you’re using is attempting to use an algorithm or key size which is no longer allowed by default with OpenSSL 3.0. A command-line option, --openssl-legacy-provider, has been added to revert to the legacy provider as a temporary workaround for these tightened restrictions.

For details about all the features in OpenSSL 3.0 please see the OpenSSL 3.0 release blog.

Contributed in github.com/nodejs/node…github.com/nodejs/node…