报错信息如下:
Building for production...Error: error:0308010C:digital envelope routines::unsupported
at new Hash (node:internal/crypto/hash:69:19)
at Object.createHash (node:crypto:133:10)
at module.exports (/Users/wanzhou/PhpstormProjects/HealthExam_Guide/frontend/manager/node_modules/webpack/lib/util/createHash.js:135:53)
at NormalModule._initBuildHash (/Users/wanzhou/PhpstormProjects/HealthExam_Guide/frontend/manager/node_modules/webpack/lib/NormalModule.js:417:16)
at handleParseError (/Users/wanzhou/PhpstormProjects/HealthExam_Guide/frontend/manager/node_modules/webpack/lib/NormalModule.js:471:10)
at /Users/wanzhou/PhpstormProjects/HealthExam_Guide/frontend/manager/node_modules/webpack/lib/NormalModule.js:503:5
at /Users/wanzhou/PhpstormProjects/HealthExam_Guide/frontend/manager/node_modules/webpack/lib/NormalModule.js:358:12
at /Users/wanzhou/PhpstormProjects/HealthExam_Guide/frontend/manager/node_modules/loader-runner/lib/LoaderRunner.js:373:3
at iterateNormalLoaders (/Users/wanzhou/PhpstormProjects/HealthExam_Guide/frontend/manager/node_modules/loader-runner/lib/LoaderRunner.js:214:10)
at iterateNormalLoaders (/Users/wanzhou/PhpstormProjects/HealthExam_Guide/frontend/manager/node_modules/loader-runner/lib/LoaderRunner.js:221:10)
at /Users/wanzhou/PhpstormProjects/HealthExam_Guide/frontend/manager/node_modules/loader-runner/lib/LoaderRunner.js:236:3
at runSyncOrAsync (/Users/wanzhou/PhpstormProjects/HealthExam_Guide/frontend/manager/node_modules/loader-runner/lib/LoaderRunner.js:130:11)
at iterateNormalLoaders (/Users/wanzhou/PhpstormProjects/HealthExam_Guide/frontend/manager/node_modules/loader-runner/lib/LoaderRunner.js:232:2)
at Array.<anonymous> (/Users/wanzhou/PhpstormProjects/HealthExam_Guide/frontend/manager/node_modules/loader-runner/lib/LoaderRunner.js:205:4)
at Storage.finished (/Users/wanzhou/PhpstormProjects/HealthExam_Guide/frontend/manager/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:55:16)
at /Users/wanzhou/PhpstormProjects/HealthExam_Guide/frontend/manager/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:91:9
⠸ Building for production.../Users/wanzhou/PhpstormProjects/HealthExam_Guide/frontend/manager/node_modules/loader-runner/lib/LoaderRunner.js:114
throw e;
^
Error: error:0308010C:digital envelope routines::unsupported
at new Hash (node:internal/crypto/hash:69:19)
at Object.createHash (node:crypto:133:10)
at module.exports (/Users/wanzhou/PhpstormProjects/HealthExam_Guide/frontend/manager/node_modules/webpack/lib/util/createHash.js:135:53)
at NormalModule._initBuildHash (/Users/wanzhou/PhpstormProjects/HealthExam_Guide/frontend/manager/node_modules/webpack/lib/NormalModule.js:417:16)
at handleParseError (/Users/wanzhou/PhpstormProjects/HealthExam_Guide/frontend/manager/node_modules/webpack/lib/NormalModule.js:471:10)
at /Users/wanzhou/PhpstormProjects/HealthExam_Guide/frontend/manager/node_modules/webpack/lib/NormalModule.js:503:5
at /Users/wanzhou/PhpstormProjects/HealthExam_Guide/frontend/manager/node_modules/webpack/lib/NormalModule.js:358:12
at /Users/wanzhou/PhpstormProjects/HealthExam_Guide/frontend/manager/node_modules/loader-runner/lib/LoaderRunner.js:373:3
at iterateNormalLoaders (/Users/wanzhou/PhpstormProjects/HealthExam_Guide/frontend/manager/node_modules/loader-runner/lib/LoaderRunner.js:214:10)
at /Users/wanzhou/PhpstormProjects/HealthExam_Guide/frontend/manager/node_modules/loader-runner/lib/LoaderRunner.js:186:6
at context.callback (/Users/wanzhou/PhpstormProjects/HealthExam_Guide/frontend/manager/node_modules/loader-runner/lib/LoaderRunner.js:111:13)
at /Users/wanzhou/PhpstormProjects/HealthExam_Guide/frontend/manager/node_modules/cache-loader/dist/index.js:240:7
at /Users/wanzhou/PhpstormProjects/HealthExam_Guide/frontend/manager/node_modules/neo-async/async.js:2830:7
at done (/Users/wanzhou/PhpstormProjects/HealthExam_Guide/frontend/manager/node_modules/neo-async/async.js:2865:11)
at /Users/wanzhou/PhpstormProjects/HealthExam_Guide/frontend/manager/node_modules/neo-async/async.js:2818:7
at /Users/wanzhou/PhpstormProjects/HealthExam_Guide/frontend/manager/node_modules/cache-loader/dist/index.js:229:9 {
opensslErrorStack: [ 'error:03000086:digital envelope routines::initialization error' ],
library: 'digital envelope routines',
reason: 'unsupported',
code: 'ERR_OSSL_EVP_UNSUPPORTED'
}
产生原因
由于你的node版本太高了,也可以降低版本,不过这不是一个优雅的解决办法
解决办法
添加环境变量即可解决,mac如何添加环境变量才有效果呢,windows如何解决这里不做描述了,网上太多教程了。打开Mac的命令终端执行如下命令:
vim ~/.zshrc
新增如下内容:
export NODE_OPTIONS=--openssl-legacy-provider
然后:wq 保存保存后执行重载配置命令:
source ~/.zshrc
总结
网上大部分教程是 sudo vim ~/.bash_profile 但是发现重启Mac后又不行了。所以推荐修改zsh的环境变量即可。