npm run dev error:0308010C:digital envelope routines::unsupported

error:0308010C:digital envelope routines::unsupported

发现场景:npm run dev 造成下方错误

问题产生原因:node 版本过高

在node.js V17以前一些可以正常运行的的应用程序,但是在 V17 /V18 版本可能会抛出异常

rror: error:0308010C:digital envelope routines::unsupported
at new Hash (node:internal/crypto/hash:67:19)
at Object.createHash (node:crypto:133:10)
at module.exports (/Users/libeibei/vueCode/b2c-shop-view/node_modules/[email protected]@webpack/lib/util/createHash.js:135:53)
at NormalModule._initBuildHash (/Users/libeibei/vueCode/b2c-shop-view/node_modules/[email protected]@webpack/lib/NormalModule.js:417:16)
at handleParseError (/Users/libeibei/vueCode/b2c-shop-view/node_modules/[email protected]@webpack/lib/NormalModule.js:471:10)
at /Users/libeibei/vueCode/b2c-shop-view/node_modules/[email protected]@webpack/lib/NormalModule.js:503:5
at /Users/libeibei/vueCode/b2c-shop-view/node_modules/[email protected]@webpack/lib/NormalModule.js:358:12
at /Users/libeibei/vueCode/b2c-shop-view/node_modules/[email protected]@loader-runner/lib/LoaderRunner.js:373:3
at iterateNormalLoaders (/Users/libeibei/vueCode/b2c-shop-view/node_modules/[email protected]@loader-runner/lib/LoaderRunner.js:214:10)
at iterateNormalLoaders (/Users/libeibei/vueCode/b2c-shop-view/node_modules/[email protected]@loader-runner/lib/LoaderRunner.js:221:10)
at /Users/libeibei/vueCode/b2c-shop-view/node_modules/[email protected]@loader-runner/lib/LoaderRunner.js:236:3
at runSyncOrAsync (/Users/libeibei/vueCode/b2c-shop-view/node_modules/[email protected]@loader-runner/lib/LoaderRunner.js:130:11)
at iterateNormalLoaders (/Users/libeibei/vueCode/b2c-shop-view/node_modules/[email protected]@loader-runner/lib/LoaderRunner.js:232:2)
at Array. (/Users/libeibei/vueCode/b2c-shop-view/node_modules/[email protected]@loader-runner/lib/LoaderRunner.js:205:4)
at Storage.finished (/Users/libeibei/vueCode/b2c-shop-view/node_modules/[email protected]@enhanced-resolve/lib/CachedInputFileSystem.js:55:16)
at /Users/libeibei/vueCode/b2c-shop-view/node_modules/[email protected]@enhanced-resolve/lib/CachedInputFileSystem.js:91:9
10% building 2/5 modules 3 active /Users/libeibei/vueCode/b2c-shop-view/node_modules/[email protected]@webpack/hot/dev-server.jsnode:internal/crypto/hash:67
this[kHandle] = new _Hash(algorithm, xofLen);
^

Error: error:0308010C:digital envelope routines::unsupported
at new Hash (node:internal/crypto/hash:67:19)
at Object.createHash (node:crypto:133:10)
at module.exports (/Users/libeibei/vueCode/b2c-shop-view/node_modules/[email protected]@webpack/lib/util/createHash.js:135:53)
at NormalModule._initBuildHash (/Users/libeibei/vueCode/b2c-shop-view/node_modules/[email protected]@webpack/lib/NormalModule.js:417:16)
at handleParseError (/Users/libeibei/vueCode/b2c-shop-view/node_modules/[email protected]@webpack/lib/NormalModule.js:471:10)
at /Users/libeibei/vueCode/b2c-shop-view/node_modules/[email protected]@webpack/lib/NormalModule.js:503:5
at /Users/libeibei/vueCode/b2c-shop-view/node_modules/[email protected]@webpack/lib/NormalModule.js:358:12
at /Users/libeibei/vueCode/b2c-shop-view/node_modules/[email protected]@loader-runner/lib/LoaderRunner.js:373:3
at iterateNormalLoaders (/Users/libeibei/vueCode/b2c-shop-view/node_modules/[email protected]@loader-runner/lib/LoaderRunner.js:214:10)
at Array. (/Users/libeibei/vueCode/b2c-shop-view/node_modules/[email protected]@loader-runner/lib/LoaderRunner.js:205:4)
at Storage.finished (/Users/libeibei/vueCode/b2c-shop-view/node_modules/[email protected]@enhanced-resolve/lib/CachedInputFileSystem.js:55:16)
at /Users/libeibei/vueCode/b2c-shop-view/node_modules/[email protected]@enhanced-resolve/lib/CachedInputFileSystem.js:91:9
at /Users/libeibei/vueCode/b2c-shop-view/node_modules/[email protected]@graceful-fs/graceful-fs.js:123:16
at FSReqCallback.readFileAfterClose [as oncomplete] (node:internal/fs/read_file_context:68:3) {
opensslErrorStack: [ ‘error:03000086:digital envelope routines::initialization error’ ],
library: ‘digital envelope routines’,
reason: ‘unsupported’,
code: ‘ERR_OSSL_EVP_UNSUPPORTED’
}

Node.js v18.3.0

解决方案

第一种我是在网上查的,我试了试没解决,就重装了node
1.命令终端运行以下代码 export NODE_OPTIONS=--openssl-legacy-provider
2.下载node版本 v16.15.1,这个版本比较稳定

你可能感兴趣的:(npm,npm)