我在两个不同的文件夹'客户端'(前端)和'服务器'(后端)工作react webapp在ec2服务器上,我从git中克隆了我的项目,并在客户端文件夹中启动NPM安装。然后输入NPM run build。最后我在下面遇到了错误。我不知道这个错误是怎么回事…
Creating an optimized production build...
Error: error:0308010C:digital envelope routines::unsupported
at new Hash (node:internal/crypto/hash:67:19)
at Object.createHash (node:crypto:130:10)
at module.exports (/home/ec2-user/seezzle/client/node_modules/webpack/lib/util/createHash.js:135:53)
at NormalModule._initBuildHash (/home/ec2-user/seezzle/client/node_modules/webpack/lib/NormalModule.js:417:16)
at handleParseError (/home/ec2-user/seezzle/client/node_modules/webpack/lib/NormalModule.js:471:10)
at /home/ec2-user/seezzle/client/node_modules/webpack/lib/NormalModule.js:503:5
at /home/ec2-user/seezzle/client/node_modules/webpack/lib/NormalModule.js:358:12
at /home/ec2-user/seezzle/client/node_modules/loader-runner/lib/LoaderRunner.js:373:3
at iterateNormalLoaders (/home/ec2-user/seezzle/client/node_modules/loader-runner/lib/LoaderRunner.js:214:10)
at iterateNormalLoaders (/home/ec2-user/seezzle/client/node_modules/loader-runner/lib/LoaderRunner.js:221:10)
at /home/ec2-user/seezzle/client/node_modules/loader-runner/lib/LoaderRunner.js:236:3
at runSyncOrAsync (/home/ec2-user/seezzle/client/node_modules/loader-runner/lib/LoaderRunner.js:130:11)
at iterateNormalLoaders (/home/ec2-user/seezzle/client/node_modules/loader-runner/lib/LoaderRunner.js:232:2)
at Array.<anonymous> (/home/ec2-user/seezzle/client/node_modules/loader-runner/lib/LoaderRunner.js:205:4)
at Storage.finished (/home/ec2-user/seezzle/client/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:55:16)
at /home/ec2-user/seezzle/client/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:91:9
/home/ec2-user/seezzle/client/node_modules/react-scripts/scripts/build.js:19
throw err;
^
Error: error:0308010C:digital envelope routines::unsupported
at new Hash (node:internal/crypto/hash:67:19)
at Object.createHash (node:crypto:130:10)
at module.exports (/home/ec2-user/seezzle/client/node_modules/webpack/lib/util/createHash.js:135:53)
at NormalModule._initBuildHash (/home/ec2-user/seezzle/client/node_modules/webpack/lib/NormalModule.js:417:16)
at /home/ec2-user/seezzle/client/node_modules/webpack/lib/NormalModule.js:452:10
at /home/ec2-user/seezzle/client/node_modules/webpack/lib/NormalModule.js:323:13
at /home/ec2-user/seezzle/client/node_modules/loader-runner/lib/LoaderRunner.js:367:11
at /home/ec2-user/seezzle/client/node_modules/loader-runner/lib/LoaderRunner.js:233:18
at context.callback (/home/ec2-user/seezzle/client/node_modules/loader-runner/lib/LoaderRunner.js:111:13)
at /home/ec2-user/seezzle/client/node_modules/babel-loader/lib/index.js:59:103 {
opensslErrorStack: [ 'error:03000086:digital envelope routines::initialization error' ],
library: 'digital envelope routines',
reason: 'unsupported',
code: 'ERR_OSSL_EVP_UNSUPPORTED'
}
验证您的Node版本是否为LTS版本14.x.x
node --version
尝试卸载当前并安装LTS https://nodejs.org/en/download/
试试这个命令
export NODE_OPTIONS=--openssl-legacy-provider
我修复了将节点版本降级到LTS的问题。我在node.17X中遇到了这个问题。当我降级到16.12.0 LTS我的问题解决了