0

Upgrading to Node v18 but when I start the app I am getting the error:

Starting the development server...

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 (/Users/user/src/my-app/node_modules/react-scripts/node_modules/webpack/lib/util/createHash.js:135:53)
    at NormalModule._initBuildHash (/Users/user/src/my-app/node_modules/react-scripts/node_modules/webpack/lib/NormalModule.js:417:16)
    at handleParseError (/Users/user/src/my-app/node_modules/react-scripts/node_modules/webpack/lib/NormalModule.js:471:10)
    at /Users/user/src/my-app/node_modules/react-scripts/node_modules/webpack/lib/NormalModule.js:503:5
    at /Users/user/src/my-app/node_modules/react-scripts/node_modules/webpack/lib/NormalModule.js:358:12
    at /Users/user/src/my-app/node_modules/loader-runner/lib/LoaderRunner.js:373:3
    at iterateNormalLoaders (/Users/user/src/my-app/node_modules/loader-runner/lib/LoaderRunner.js:214:10)
    at iterateNormalLoaders (/Users/user/src/my-app/node_modules/loader-runner/lib/LoaderRunner.js:221:10)
/Users/user/src/my-app/node_modules/react-scripts/scripts/start.js:19
  throw err;
  ^

Have tried solutions from this other thread. I've tried updating the webpack config (or in my case the react-app-rewired config) to include:

module.exports = {
  webpack: (config, env) => {
    config.output.hashFunction = 'xxhash64';
    return config;
  },
};

but that just leads to the error:

Error: Digest method not supported
    at new Hash (node:internal/crypto/hash:71:19)
    at Object.createHash (node:crypto:133:10)

I also tried setting the hashFunction to sha256 and sha512 but they result in the original digital envelope error.

I also tried npm audit --fix but the error remains.

I am able to start the app if I prepend the run command in package.json with NODE_OPTIONS='--openssl-legacy-provider':

  "scripts": {
    "start": "NODE_OPTIONS='--openssl-legacy-provider' react-app-rewired start",
    ...

Is that the only solution to this? Thanks.

Alan P.
  • 2,898
  • 6
  • 28
  • 52
  • It’s that or change your node/webpack versions. – morganney Jun 29 '23 at 22:58
  • Welp, i'm on the latest `react-scripts` and I imagine newer versions of Node would need this as well, since I believe the "cause" of the error was Node 17 closing a security hole in the SSL provider (according to the other ticket I linked to). – Alan P. Jun 30 '23 at 16:56

0 Answers0