问题描述:
使用最新的npx create-react-app my-app创建了个react项目
使用npm start启动就报错了:
Error: error:0308010C:digital envelope routines::unsupported
at new Hash (node:internal/crypto/hash:71:19)
at (node:crypto:133:10)
at (/data2/github/frontend/react/wasm-image-map/node_modules/webpack/lib/util/:90:53)
at NormalModule._initBuildHash (/data2/github/frontend/react/wasm-image-map/node_modules/webpack/lib/:386:16)
at handleParseError (/data2/github/frontend/react/wasm-image-map/node_modules/webpack/lib/:434:10)
at /data2/github/frontend/react/wasm-image-map/node_modules/webpack/lib/:466:5
at /data2/github/frontend/react/wasm-image-map/node_modules/webpack/lib/:327:12
at /data2/github/frontend/react/wasm-image-map/node_modules/loader-runner/lib/:373:3
at iterateNormalLoaders (/data2/github/frontend/react/wasm-image-map/node_modules/loader-runner/lib/:214:10)
at iterateNormalLoaders (/data2/github/frontend/react/wasm-image-map/node_modules/loader-runner/lib/:221:10)
at /data2/github/frontend/react/wasm-image-map/node_modules/loader-runner/lib/:236:3
at runSyncOrAsync (/data2/github/frontend/react/wasm-image-map/node_modules/loader-runner/lib/:130:11)
at iterateNormalLoaders (/data2/github/frontend/react/wasm-image-map/node_modules/loader-runner/lib/:232:2)
at Array.<anonymous> (/data2/github/frontend/react/wasm-image-map/node_modules/loader-runner/lib/:205:4)
at (/data2/github/frontend/react/wasm-image-map/node_modules/enhanced-resolve/lib/:55:16)
at /data2/github/frontend/react/wasm-image-map/node_modules/enhanced-resolve/lib/:91:9
/data2/github/frontend/react/wasm-image-map/node_modules/react-scripts/scripts/:19
throw err;
^Error: error:0308010C:digital envelope routines::unsupported
at new Hash (node:internal/crypto/hash:71:19)
at (node:crypto:133:10)
at (/data2/github/frontend/react/wasm-image-map/node_modules/webpack/lib/util/:90:53)
at NormalModule._initBuildHash (/data2/github/frontend/react/wasm-image-map/node_modules/webpack/lib/:386:16)
at /data2/github/frontend/react/wasm-image-map/node_modules/webpack/lib/:418:10
at /data2/github/frontend/react/wasm-image-map/node_modules/webpack/lib/:293:13
at /data2/github/frontend/react/wasm-image-map/node_modules/loader-runner/lib/:367:11
at /data2/github/frontend/react/wasm-image-map/node_modules/loader-runner/lib/:233:18
at (/data2/github/frontend/react/wasm-image-map/node_modules/loader-runner/lib/:111:13)
at /data2/github/frontend/react/wasm-image-map/node_modules/babel-loader/lib/:51:103 {
opensslErrorStack: [ 'error:03000086:digital envelope routines::initialization error' ],
library: 'digital envelope routines',
reason: 'unsupported',
code: 'ERR_OSSL_EVP_UNSUPPORTED'
}v18.12.0
解决方法:
设置环境变量
在ubuntu下可以把这行添加到~/.bashrc里:
export NODE_OPTIONS=--openssl-legacy-provider
也可以每次执行npm start时设置 NODE_OPTIONS=--openssl-legacy-provider npm start