# node 启动和运行中的问题
高版本 node(>16) 启动时出现 openssl 报错
Error: error:0308010C:digital envelope routines::unsupported
... {
opensslErrorStack: [ 'error:03000086:digital envelope routines::initialization error' ],
library: 'digital envelope routines',
reason: 'unsupported',
code: 'ERR_OSSL_EVP_UNSUPPORTED'
}
原因是 node 更新了 openssl,Node.js v12.x, v14.x and v16.x use OpenSSL v1.1.1 and Node.js v17.x uses OpenSSL v3.
每次启动前,可在命令行执行如下代码解决
# Linux/mac
export NODE_OPTIONS=--openssl-legacy-provide
# windows
set NODE_OPTIONS=--openssl-legacy-provider
或者修改 package.json 里对应的启动脚本,如
export NODE_OPTIONS=--openssl-legacy-provider && vue-cli-service serve