前端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
*/
将NodeJS版本版本降低到项目制定的版本; 在重新安装之前,一定要卸载干净,具体的卸载方式可以参考这个链接: windows如何把已安装的nodejs高版本降级为低版本(图文教程)
该方法不降级NodeJS,适用于降级也无效的情况下,需要在npm run serve项目启动前声明条件变量; windows在命令行依次输入如下2个命令:
$env:NODE_OPTIONS="--openssl-legacy-provider"
npm start
Linux:
NODE_OPTIONS=--openssl-legacy-provider npm start
Webpack build failing with ERR_OSSL_EVP_UNSUPPORTED [duplicate]