npm:运行进报错:error:0308010C:digital envelope routines::unsupported

一,报错信息:

 this[kHandle] = new _Hash(algorithm, xofLen, algorithmId, getHashCache());
                  ^

Error: error:0308010C:digital envelope routines::unsupported
    at new Hash (node:internal/crypto/hash:101:19)
    at Object.createHash (node:crypto:139:10)
    at module.exports (/data/vue_thn/thn-dtp-master/node_modules/webpack/lib/util/createHash.js:135:53)
    at NormalModule._initBuildHash (/data/vue_thn/thn-dtp-master/node_modules/webpack/lib/NormalModule.js:417:16)
    at handleParseError (/data/vue_thn/thn-dtp-master/node_modules/webpack/lib/NormalModule.js:471:10)

二,原因:

Node.js 17 默认使用 OpenSSL 3.0,而 OpenSSL 3.0 对某些算法(如 SHA-1 和 MD5)的支持有所限制。
如果你的代码或依赖的库使用了这些不再支持的算法,就会触发这个错误。

你可以通过设置环境变量来指定使用 OpenSSL 1.1.1 或更低版本,这可以通过以下命令完成:

export NODE_OPTIONS=--openssl-legacy-provider

三,解决:

$ export NODE_OPTIONS=--openssl-legacy-provider;
$ npm run dev

 

posted @ 2026-01-15 21:53  刘宏缔的架构森林  阅读(6)  评论(0)    收藏  举报