Skip to content

Fail to build on Ubuntu 22.04 with yarn 1.22.19 and node 18.16.0

The application fails to build on Ubuntu 22.04 with yarn 1.22.19 and node 18.16.0.

Here's the error:

# yarn build
yarn run v1.22.19
$ react-scripts build
Creating an optimized production build...
Error: error:0308010C:digital envelope routines::unsupported
    at new Hash (node:internal/crypto/hash:71:19)
    at Object.createHash (node:crypto:133:10)
    at module.exports (/var/www/html/tree-online/node_modules/webpack/lib/util/createHash.js:135:53)
    at NormalModule._initBuildHash (/var/www/html/tree-online/node_modules/webpack/lib/NormalModule.js:417:16)
    at handleParseError (/var/www/html/tree-online/node_modules/webpack/lib/NormalModule.js:471:10)
    at /var/www/html/tree-online/node_modules/webpack/lib/NormalModule.js:503:5
    at /var/www/html/tree-online/node_modules/webpack/lib/NormalModule.js:358:12
    at /var/www/html/tree-online/node_modules/loader-runner/lib/LoaderRunner.js:373:3
    at iterateNormalLoaders (/var/www/html/tree-online/node_modules/loader-runner/lib/LoaderRunner.js:214:10)
    at iterateNormalLoaders (/var/www/html/tree-online/node_modules/loader-runner/lib/LoaderRunner.js:221:10)
/var/www/html/tree-online/node_modules/react-scripts/scripts/build.js:19
  throw err;
  ^

Error: error:0308010C:digital envelope routines::unsupported
    at new Hash (node:internal/crypto/hash:71:19)
    at Object.createHash (node:crypto:133:10)
    at module.exports (/var/www/html/tree-online/node_modules/webpack/lib/util/createHash.js:135:53)
    at NormalModule._initBuildHash (/var/www/html/tree-online/node_modules/webpack/lib/NormalModule.js:417:16)
    at /var/www/html/tree-online/node_modules/webpack/lib/NormalModule.js:452:10
    at /var/www/html/tree-online/node_modules/webpack/lib/NormalModule.js:323:13
    at /var/www/html/tree-online/node_modules/loader-runner/lib/LoaderRunner.js:367:11
    at /var/www/html/tree-online/node_modules/loader-runner/lib/LoaderRunner.js:233:18
    at context.callback (/var/www/html/tree-online/node_modules/loader-runner/lib/LoaderRunner.js:111:13)
    at /var/www/html/tree-online/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.js v18.16.0
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Edited by PeGaSuS