Vue學習筆記之opensslErrorStack: [ ‘error:03000086:digital envelope routines::initialization error‘ ]的問題

0x00 概述

前端Vue項目啓動報錯如下:

/**

<s> [webpack.Progress] 10% building 0/1 entries 0/0 dependencies 0/0 modules
node: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:130:10)
at BulkUpdateDecorator.hashFactory (/app/node_modules/webpack/lib/util/createHash.js:155:18)
at BulkUpdateDecorator.update (/app/node_modules/webpack/lib/util/createHash.js:46:50)
at OriginalSource.updateHash (/app/node_modules/webpack-sources/lib/OriginalSource.js:131:8)
at NormalModule._initBuildHash (/app/node_modules/webpack/lib/NormalModule.js:888:17)
at handleParseResult (/app/node_modules/webpack/lib/NormalModule.js:954:10)
at /app/node_modules/webpack/lib/NormalModule.js:1048:4
at processResult (/app/node_modules/webpack/lib/NormalModule.js:763:11)
at /app/node_modules/webpack/lib/NormalModule.js:827:5 {
opensslErrorStack: [ 'error:03000086:digital envelope routines::initialization error' ],
library: 'digital envelope routines',
reason: 'unsupported',
code: 'ERR_OSSL_EVP_UNSUPPORTED'
}
command terminated with exit code 1

*/

 

0x01 NodeJS版本過高

將NodeJS版本版本降低到項目制定的版本;
在重新安裝之前,一定要卸載乾淨,具體的卸載方式可以參考這個鏈接:
windows如何把已安裝的nodejs高版本降級爲低版本(圖文教程)

 

0x02 添加項目啓動參數

該方法不降級NodeJS,適用於降級也無效的情況下,需要在npm run serve項目啓動前聲明條件變量;
windows在命令行依次輸入如下2個命令:

$env:NODE_OPTIONS="--openssl-legacy-provider"

npm start

Linux:

NODE_OPTIONS=--openssl-legacy-provider npm start

 

0x03 參考

Webpack build failing with ERR_OSSL_EVP_UNSUPPORTED [duplicate]

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章