问题描述: 前端项目自定义webpack自动构建项目,启动时报错:Error: error:0308010C:digital envelope routines::unsupported
报错原因:
主要是因为 nodeJs V17 版本发布了 OpenSSL3.0 对算法和秘钥大小增加了更为严格的限制,nodeJs v17 之前版本没影响,但 V17 和之后版本会出现这个错误。 我的node版本是v18+
报错详细信息:
Error: error:0308010C:digital envelope routines::unsupported at new Hash (node:internal/crypto/hash:71:19) at Object.createHash (node:crypto:133:10) at filename (E:\roof\cobase_webclient\node_modules\babel-loader\lib\fs-cache.js:76:21) at E:\roof\cobase_webclient\node_modules\babel-loader\lib\fs-cache.js:107:37 at E:\roof\cobase_webclient\node_modules\mkdirp\index.js:51:26 at FSReqCallback.oncomplete (node:fs:209:5) { opensslErrorStack: [ 'error:03000086:digital envelope routines::initialization error' ], library: 'digital envelope routines', reason: 'unsupported', code: 'ERR_OSSL_EVP_UNSUPPORTED' } Node.js v18.16.1 HappyThread[0]: unable to send to worker! Error: write EPIPE at target._send (node:internal/child_process:865:20) at target.send (node:internal/child_process:738:19) at processSend (E:\roof\cobase_webclient\node_modules\happypack\lib\processSend.js:8:15) at deliver (E:\roof\cobase_webclient\node_modules\happypack\lib\BufferedFd.js:26:3) at E:\roof\cobase_webclient\node_modules\happypack\lib\BufferedFd.js:33:9 at process.processTicksAndRejections (node:internal/process/task_queues:77:11) { errno: -4047, code: 'EPIPE', syscall: 'write' } HappyThread[0]: unable to send to worker! Error: write EPIPE at target._send (node:internal/child_process:865:20) at target.send (node:internal/child_process:738:19) at processSend (E:\roof\cobase_webclient\node_modules\happypack\lib\processSend.js:8:15) at deliver (E:\roof\cobase_webclient\node_modules\happypack\lib\BufferedFd.js:26:3) at E:\roof\cobase_webclient\node_modules\happypack\lib\BufferedFd.js:33:9 at process.processTicksAndRejections (node:internal/process/task_queues:77:11) { errno: -4047, code: 'EPIPE', syscall: 'write' } 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) at filename (E:\roof\cobase_webclient\node_modules\babel-loader\lib\fs-cache.js:76:21) at E:\roof\cobase_webclient\node_modules\babel-loader\lib\fs-cache.js:107:37 at E:\roof\cobase_webclient\node_modules\mkdirp\index.js:51:26 at FSReqCallback.oncomplete (node:fs:209:5) { opensslErrorStack: [ 'error:03000086:digital envelope routines::initialization error' ], library: 'digital envelope routines', reason: 'unsupported', code: 'ERR_OSSL_EVP_UNSUPPORTED' } Node.js v18.16.1 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) at filename (E:\roof\cobase_webclient\node_modules\babel-loader\lib\fs-cache.js:76:21) at E:\roof\cobase_webclient\node_modules\babel-loader\lib\fs-cache.js:107:37 at E:\roof\cobase_webclient\node_modules\mkdirp\index.js:51:26 at FSReqCallback.oncomplete (node:fs:209:5) { opensslErrorStack: [ 'error:03000086:digital envelope routines::initialization error' ], library: 'digital envelope routines', reason: 'unsupported', code: 'ERR_OSSL_EVP_UNSUPPORTED' } Node.js v18.16.1 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) at filename (E:\roof\cobase_webclient\node_modules\babel-loader\lib\fs-cache.js:76:21) at E:\roof\cobase_webclient\node_modules\babel-loader\lib\fs-cache.js:107:37 at E:\roof\cobase_webclient\node_modules\mkdirp\index.js:51:26 at FSReqCallback.oncomplete (node:fs:209:5) { opensslErrorStack: [ 'error:03000086:digital envelope routines::initialization error' ], library: 'digital envelope routines', reason: 'unsupported', code: 'ERR_OSSL_EVP_UNSUPPORTED' } Node.js v18.16.1 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) at filename (E:\roof\cobase_webclient\node_modules\babel-loader\lib\fs-cache.js:76:21) at E:\roof\cobase_webclient\node_modules\babel-loader\lib\fs-cache.js:107:37 at E:\roof\cobase_webclient\node_modules\mkdirp\index.js:51:26 at FSReqCallback.oncomplete (node:fs:209:5) { opensslErrorStack: [ 'error:03000086:digital envelope routines::initialization error' ], library: 'digital envelope routines', reason: 'unsupported', code: 'ERR_OSSL_EVP_UNSUPPORTED' } Node.js v18.16.1 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) at filename (E:\roof\cobase_webclient\node_modules\babel-loader\lib\fs-cache.js:76:21) at E:\roof\cobase_webclient\node_modules\babel-loader\lib\fs-cache.js:107:37 at E:\roof\cobase_webclient\node_modules\mkdirp\index.js:51:26 at FSReqCallback.oncomplete (node:fs:209:5) { opensslErrorStack: [ 'error:03000086:digital envelope routines::initialization error' ], library: 'digital envelope routines', reason: 'unsupported', code: 'ERR_OSSL_EVP_UNSUPPORTED' } Node.js v18.16.1 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) at filename (E:\roof\cobase_webclient\node_modules\babel-loader\lib\fs-cache.js:76:21) at E:\roof\cobase_webclient\node_modules\babel-loader\lib\fs-cache.js:107:37 at E:\roof\cobase_webclient\node_modules\mkdirp\index.js:51:26 at FSReqCallback.oncomplete (node:fs:209:5) { opensslErrorStack: [ 'error:03000086:digital envelope routines::initialization error' ], library: 'digital envelope routines', reason: 'unsupported', code: 'ERR_OSSL_EVP_UNSUPPORTED' } Node.js v18.16.1 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) at filename (E:\roof\cobase_webclient\node_modules\babel-loader\lib\fs-cache.js:76:21) at E:\roof\cobase_webclient\node_modules\babel-loader\lib\fs-cache.js:107:37 at E:\roof\cobase_webclient\node_modules\mkdirp\index.js:51:26 at FSReqCallback.oncomplete (node:fs:209:5) { opensslErrorStack: [ 'error:03000086:digital envelope routines::initialization error' ], library: 'digital envelope routines', reason: 'unsupported', code: 'ERR_OSSL_EVP_UNSUPPORTED' } Node.js v18.16.1 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) at filename (E:\roof\cobase_webclient\node_modules\babel-loader\lib\fs-cache.js:76:21) at E:\roof\cobase_webclient\node_modules\babel-loader\lib\fs-cache.js:107:37 at E:\roof\cobase_webclient\node_modules\mkdirp\index.js:51:26 at FSReqCallback.oncomplete (node:fs:209:5) { opensslErrorStack: [ 'error:03000086:digital envelope routines::initialization error' ], library: 'digital envelope routines', reason: 'unsupported', code: 'ERR_OSSL_EVP_UNSUPPORTED' } Node.js v18.16.1 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) at filename (E:\roof\cobase_webclient\node_modules\babel-loader\lib\fs-cache.js:76:21) at E:\roof\cobase_webclient\node_modules\babel-loader\lib\fs-cache.js:107:37 at E:\roof\cobase_webclient\node_modules\mkdirp\index.js:51:26 at FSReqCallback.oncomplete (node:fs:209:5) { opensslErrorStack: [ 'error:03000086:digital envelope routines::initialization error' ], library: 'digital envelope routines', reason: 'unsupported', code: 'ERR_OSSL_EVP_UNSUPPORTED' } Node.js v18.16.1 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) at filename (E:\roof\cobase_webclient\node_modules\babel-loader\lib\fs-cache.js:76:21) at E:\roof\cobase_webclient\node_modules\babel-loader\lib\fs-cache.js:107:37 at E:\roof\cobase_webclient\node_modules\mkdirp\index.js:51:26 at FSReqCallback.oncomplete (node:fs:209:5) { opensslErrorStack: [ 'error:03000086:digital envelope routines::initialization error' ], library: 'digital envelope routines', reason: 'unsupported', code: 'ERR_OSSL_EVP_UNSUPPORTED' } Node.js v18.16.1 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) at filename (E:\roof\cobase_webclient\node_modules\babel-loader\lib\fs-cache.js:76:21) at E:\roof\cobase_webclient\node_modules\babel-loader\lib\fs-cache.js:107:37 at E:\roof\cobase_webclient\node_modules\mkdirp\index.js:51:26 at FSReqCallback.oncomplete (node:fs:209:5) { opensslErrorStack: [ 'error:03000086:digital envelope routines::initialization error' ], library: 'digital envelope routines', reason: 'unsupported', code: 'ERR_OSSL_EVP_UNSUPPORTED' } Node.js v18.16.1 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) at filename (E:\roof\cobase_webclient\node_modules\babel-loader\lib\fs-cache.js:76:21) at E:\roof\cobase_webclient\node_modules\babel-loader\lib\fs-cache.js:107:37 at E:\roof\cobase_webclient\node_modules\mkdirp\index.js:51:26 at FSReqCallback.oncomplete (node:fs:209:5) { opensslErrorStack: [ 'error:03000086:digital envelope routines::initialization error' ], library: 'digital envelope routines', reason: 'unsupported', code: 'ERR_OSSL_EVP_UNSUPPORTED' } Node.js v18.16.1 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) at filename (E:\roof\cobase_webclient\node_modules\babel-loader\lib\fs-cache.js:76:21) at E:\roof\cobase_webclient\node_modules\babel-loader\lib\fs-cache.js:107:37 at E:\roof\cobase_webclient\node_modules\mkdirp\index.js:51:26 at FSReqCallback.oncomplete (node:fs:209:5) { opensslErrorStack: [ 'error:03000086:digital envelope routines::initialization error' ], library: 'digital envelope routines', reason: 'unsupported', code: 'ERR_OSSL_EVP_UNSUPPORTED' } Node.js v18.16.1 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) at filename (E:\roof\cobase_webclient\node_modules\babel-loader\lib\fs-cache.js:76:21) at E:\roof\cobase_webclient\node_modules\babel-loader\lib\fs-cache.js:107:37 at E:\roof\cobase_webclient\node_modules\mkdirp\index.js:51:26 at FSReqCallback.oncomplete (node:fs:209:5) { opensslErrorStack: [ 'error:03000086:digital envelope routines::initialization error' ], library: 'digital envelope routines', reason: 'unsupported', code: 'ERR_OSSL_EVP_UNSUPPORTED' } Node.js v18.16.1
解决方案:
方案1:打开IDEA 终端,直接输入
Linux & Mac OS:
export NODE_OPTIONS=--openssl-legacy-provider
Windows:
set NODE_OPTIONS=--openssl-legacy-provider
方案2:打开IDEA 终端,直接输入(问题解决)
$env:NODE_OPTIONS="--openssl-legacy-provider"
方案3:卸载当前版本,安装合适的版本(node.js)
方案4:
解决方式(仅限 windows):
在项目中 package.json 的 scripts 中新增 SET NODE_OPTIONS=--openssl-legacy-provider
添加前:
"scripts": { "server": "webpack-dev-server --env.server --env.develop --inline --max-old-space-size=3000", . . }
添加后:
"scripts": { "server": "SET NODE_OPTIONS=--openssl-legacy-provider && webpack-dev-server --env.server --env.develop --inline --max-old-space-size=3000", . . }
标签:node,0308010C,cobase,routines,modules,roof,js,digital,webclient From: https://www.cnblogs.com/litterjoan/p/18068303