Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

react-scripts fails to build project with Node 17 #11562

Open
aghArdeshir opened this issue Oct 20, 2021 · 31 comments
Open

react-scripts fails to build project with Node 17 #11562

aghArdeshir opened this issue Oct 20, 2021 · 31 comments

Comments

@aghArdeshir
Copy link

Describe the bug

we have a CRA app, it used to build with Node 14.x very fine, today I upgrade nodejs to 17.0.0 and it failed. (in both my local machine and the CI-CD machine)

And these were the logs:

> react-scripts 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 (/my-project/node_modules/webpack/lib/util/createHash.js:135:53)
    at NormalModule._initBuildHash (/my-project/node_modules/webpack/lib/NormalModule.js:417:16)
    at handleParseError (/my-project/node_modules/webpack/lib/NormalModule.js:471:10)
    at /my-project/node_modules/webpack/lib/NormalModule.js:503:5
    at /my-project/node_modules/webpack/lib/NormalModule.js:358:12
    at /my-project/node_modules/loader-runner/lib/LoaderRunner.js:373:3
    at iterateNormalLoaders (/my-project/node_modules/loader-runner/lib/LoaderRunner.js:214:10)
    at iterateNormalLoaders (/my-project/node_modules/loader-runner/lib/LoaderRunner.js:221:10)
    at /my-project/node_modules/loader-runner/lib/LoaderRunner.js:236:3
    at runSyncOrAsync (/my-project/node_modules/loader-runner/lib/LoaderRunner.js:130:11)
    at iterateNormalLoaders (/my-project/node_modules/loader-runner/lib/LoaderRunner.js:232:2)
    at Array.<anonymous> (/my-project/node_modules/loader-runner/lib/LoaderRunner.js:205:4)
    at Storage.finished (/my-project/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:55:16)
    at /my-project/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:91:9
/my-project/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 (/my-project/node_modules/webpack/lib/util/createHash.js:135:53)
    at NormalModule._initBuildHash (/my-project/node_modules/webpack/lib/NormalModule.js:417:16)
    at /my-project/node_modules/webpack/lib/NormalModule.js:452:10
    at /my-project/node_modules/webpack/lib/NormalModule.js:323:13
    at /my-project/node_modules/loader-runner/lib/LoaderRunner.js:367:11
    at /my-project/node_modules/loader-runner/lib/LoaderRunner.js:233:18
    at context.callback (/my-project/node_modules/loader-runner/lib/LoaderRunner.js:111:13)
    at /my-project/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 v17.0.0
ERROR: Job failed: exit status 1

Did you try recovering your dependencies?

yes. in both local machine and CI-CD machine I re-installed all the dependencies

Which terms did you search for in User Guide?

I searched Google for error:0308010C:digital envelope routines::unsupported with and without the 0308010C part

Environment

current version of create-react-app: 4.0.3
  running from /home/.npm/_npx/34113/lib/node_modules/create-react-app

  System:
    OS: Linux 5.13 Ubuntu 21.10 21.10 (Impish Indri)
    CPU: (4) x64 Intel(R) Core(TM) i5-4460  CPU @ 3.20GHz
  Binaries:
    Node: 17.0.0 - /usr/bin/node
    Yarn: Not Found
    npm: 8.1.0 - /usr/bin/npm
  Browsers:
    Chrome: 95.0.4638.54
    Firefox: 93.0
  npmPackages:
    react: ^16.13.1 => 16.13.1 
    react-dom: ^16.13.1 => 16.13.1 
    react-scripts: ^4.0.3 => 4.0.3 
  npmGlobalPackages:
    create-react-app: Not Found

Steps to reproduce

(Write your steps here:)

  1. create new react app with create-react-app and node 14
  2. do npm run build to see it builds completely fine
  3. upgrade to node 17 and do npm run build again to see it fail

Expected behavior

to build flawlessly

Actual behavior

The build failed with errors printed above!

Note

I know that it is mostly not related to create-react-app, but another package, maybe webpack or it's dependencies. But as I cannot dig down, I write this issue here so the professionals can track it further.

Thanks

@Gnito
Copy link

Gnito commented Oct 20, 2021

This looks like a relevant discussion related to this issue:
https://stackoverflow.com/questions/69394632/webpack-build-failing-with-err-ossl-evp-unsupported

@niels-bosman
Copy link

Having the same issue. Node 16.11.1 works but 17.0.0 and 17.0.1 are causing this error.

@aghArdeshir
Copy link
Author

Yes @Gnito that's it I think. So it is probably either Webpack's to update something, or react-scripts' to change some config, right?

@trashcoder
Copy link

trashcoder commented Oct 22, 2021

in your package.json:
change this line
"build": "react-scripts start",
to
"build": "react-scripts --openssl-legacy-provider build",

@dantman
Copy link

dantman commented Oct 25, 2021

in your package.json:
change this line
"build": "react-scripts start",
to
"build": "react-scripts --openssl-legacy-provider build",

Doing this results in a bad option: --openssl-legacy-provider error in Node 16. So this isn't a workaround projects can actually use in their scripts unless they have absolute control over the version of Node everyone uses and can prohibit use of LTS versions by anyone.

The only real fix will likely be the release of CRA v5.

@dantman
Copy link

dantman commented Oct 26, 2021

The only real fix will likely be the release of CRA v5.

Actually it seems that this won't necessarily fix the issue alone. WebPack does plan to change the default hash function in WebPack 6 but cannot change it in 4 or 5.

CRA needs to change the hashFunction and make a release. Though given CRA v4 hasn't received an update since Feb and CRA has other issues with Node 17 (#11565) I presume we'll only get that fix in CRA v5,

@niels-bosman
Copy link

Could be fixed by #11597

@HADMARINE
Copy link
Contributor

Merged #11597 just before, and currently testing on local computer.

@dantman
Copy link

dantman commented Nov 8, 2021

I tested out the @next version of CRA v5. It seems there may be some more work required in order to make Node 17 work.

I'm still getting this error but now it's due to CRA v5 still using file-loader. The implication in the WebPack thread on Node 17 is that file-loader is obsolete and the fix to file-loader breaking Node 17 is to not use file-loader because it's no longer supported.

We may need #11213 before CRA v5 will work on Node 17.

@cburk2019
Copy link

cburk2019 commented Dec 2, 2021

On MBP w/M1, running Node v17, to run React with npm start I had to change my start script to "start": "react-scripts --openssl-legacy-provider start". But when I try to run npm run deploy, it reads "/opt/homebrew/Cellar/nvm/0.38.0/versions/node/v16.13.0/bin/node: bad option: --openssl-legacy-provider"

I tried "react-scripts --openssl-legacy-provider build" and it does not work. Switched to Node v16.13.0 and it works as it came upon initialization.

"start": "react-scripts --openssl-legacy-provider start",
"build": "react-scripts build",

Pretty annoying, but hey, I've heard things change all the change in this industry and a few months from now, someone will see this comment and things will be different then as well.

@KiraLT
Copy link

KiraLT commented Dec 21, 2021

If you need to support both 17 and older NodeJS versions you can use if-node-version to execute different commands for different NodeJS versions:

{
    "scripts": {
        "build": "if-node-version '>= 17' && react-scripts --openssl-legacy-provider build || react-scripts build",
    }
}

@sorenhoyer
Copy link

Looks like this has been fixed.

@patbi
Copy link

patbi commented Oct 30, 2022

It work Thanks.

"scripts": {
"start": "react-scripts --openssl-legacy-provider start",
"build": "react-scripts --openssl-legacy-provider build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},

@linux019
Copy link

linux019 commented Nov 8, 2022

why not to pass to webpack config to use some modern hash function instead of deprecated md4 https://webpack.js.org/configuration/output/#outputhashfunction ?

@aprilmintacpineda
Copy link

CRA is now a tech debt.

@Mussassa
Copy link

It work Thanks.

"scripts": { "start": "react-scripts --openssl-legacy-provider start", "build": "react-scripts --openssl-legacy-provider build", "test": "react-scripts test", "eject": "react-scripts eject" },

Thanks Pat! That worked for me also.

@MohibullahHABIBZAI
Copy link

11562

longsleep added a commit to longsleep-io/lico that referenced this issue May 11, 2023
Node 17 fixed a security issue related to crypto which is incompatible
with the current default settings of webpack used via react-scripts.
This is unfortunate and this change thus adds a special node commandline
argument to make Node 17 use the previous behavior.

Reference: facebook/create-react-app#11562
longsleep added a commit to libregraph/lico that referenced this issue May 11, 2023
Node 17 fixed a security issue related to crypto which is incompatible
with the current default settings of webpack used via react-scripts.
This is unfortunate and this change thus adds a special node commandline
argument to make Node 17 use the previous behavior.

Reference: facebook/create-react-app#11562
@eladonline
Copy link

for react-app-rewired use it like this
"start": "react-app-rewired --openssl-legacy-provider start ",

tsmock added a commit to facebook/OSM-HOT-Tasking-Manager that referenced this issue Sep 8, 2023
…OL is 2023-09-11

This does the following:
* Add NODE_OPTIONS=--openssl-legacy-provider (not needed once we upgrade
  to react-scripts v5 or remove/replace react-scripts)
* Only adds NODE_OPTIONS when run on node 18 or later
* Performs frontend-code-test on node 18
* Does _not_ run backend_deploy/frontend_deploy with node 18. This can
  be changed via using cimg/python:3.10-node (versions after 3.10.8-node
  use node 18 instead of node 16)

Node 16 EOL Notice: https://nodejs.org/en/blog/announcements/nodejs16-eol
create-react-app --openssl-legacy-provider: facebook/create-react-app#11562

Signed-off-by: Taylor Smock <tsmock@meta.com>
@Palinan1985
Copy link

Hell

@guychou7
Copy link

I had the same issue with Node v18.13.0
Fix step:
install nvm
upgrade node version to 20.3.0 via cmd nvm install v20.0.3
do npm -v must be 9.6.7

Test again npm run build

@Paulk58
Copy link

Paulk58 commented Nov 5, 2023

Kinding58 Wallet has been created successfully

@Paulk58
Copy link

Paulk58 commented Nov 5, 2023

Kinding58 Wallet shall be used for various pi transactions

@Paulk58
Copy link

Paulk58 commented Nov 5, 2023

It's done

@Paulk58
Copy link

Paulk58 commented Nov 10, 2023

This is Paulk58 Netface Wallet created on 10th November 2023

@Paulk58
Copy link

Paulk58 commented Nov 10, 2023

This is Paulk58 Whatsapp wallet re-created on 10 th November 2023

@Paulk58
Copy link

Paulk58 commented Nov 10, 2023

This is Paulk58 Whatsapp wallet re-created on 10 November 2023

@Roberthimmotta
Copy link

Describe the bug

we have a CRA app, it used to build with Node 14.x very fine, today I upgrade nodejs to 17.0.0 and it failed. (in both my local machine and the CI-CD machine)

And these were the logs:


> react-scripts 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 (/my-project/node_modules/webpack/lib/util/createHash.js:135:53)

    at NormalModule._initBuildHash (/my-project/node_modules/webpack/lib/NormalModule.js:417:16)

    at handleParseError (/my-project/node_modules/webpack/lib/NormalModule.js:471:10)

    at /my-project/node_modules/webpack/lib/NormalModule.js:503:5

    at /my-project/node_modules/webpack/lib/NormalModule.js:358:12

    at /my-project/node_modules/loader-runner/lib/LoaderRunner.js:373:3

    at iterateNormalLoaders (/my-project/node_modules/loader-runner/lib/LoaderRunner.js:214:10)

    at iterateNormalLoaders (/my-project/node_modules/loader-runner/lib/LoaderRunner.js:221:10)

    at /my-project/node_modules/loader-runner/lib/LoaderRunner.js:236:3

    at runSyncOrAsync (/my-project/node_modules/loader-runner/lib/LoaderRunner.js:130:11)

    at iterateNormalLoaders (/my-project/node_modules/loader-runner/lib/LoaderRunner.js:232:2)

    at Array.<anonymous> (/my-project/node_modules/loader-runner/lib/LoaderRunner.js:205:4)

    at Storage.finished (/my-project/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:55:16)

    at /my-project/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:91:9

/my-project/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 (/my-project/node_modules/webpack/lib/util/createHash.js:135:53)

    at NormalModule._initBuildHash (/my-project/node_modules/webpack/lib/NormalModule.js:417:16)

    at /my-project/node_modules/webpack/lib/NormalModule.js:452:10

    at /my-project/node_modules/webpack/lib/NormalModule.js:323:13

    at /my-project/node_modules/loader-runner/lib/LoaderRunner.js:367:11

    at /my-project/node_modules/loader-runner/lib/LoaderRunner.js:233:18

    at context.callback (/my-project/node_modules/loader-runner/lib/LoaderRunner.js:111:13)

    at /my-project/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 v17.0.0

ERROR: Job failed: exit status 1

Did you try recovering your dependencies?

yes. in both local machine and CI-CD machine I re-installed all the dependencies

Which terms did you search for in User Guide?

I searched Google for error:0308010C:digital envelope routines::unsupported with and without the 0308010C part

Environment


current version of create-react-app: 4.0.3

  running from /home/.npm/_npx/34113/lib/node_modules/create-react-app



  System:

    OS: Linux 5.13 Ubuntu 21.10 21.10 (Impish Indri)

    CPU: (4) x64 Intel(R) Core(TM) i5-4460  CPU @ 3.20GHz

  Binaries:

    Node: 17.0.0 - /usr/bin/node

    Yarn: Not Found

    npm: 8.1.0 - /usr/bin/npm

  Browsers:

    Chrome: 95.0.4638.54

    Firefox: 93.0

  npmPackages:

    react: ^16.13.1 => 16.13.1 

    react-dom: ^16.13.1 => 16.13.1 

    react-scripts: ^4.0.3 => 4.0.3 

  npmGlobalPackages:

    create-react-app: Not Found

Steps to reproduce

(Write your steps here:)

  1. create new react app with create-react-app and node 14

  2. do npm run build to see it builds completely fine

  3. upgrade to node 17 and do npm run build again to see it fail

Expected behavior

to build flawlessly

Actual behavior

The build failed with errors printed above!

Note

I know that it is mostly not related to create-react-app, but another package, maybe webpack or it's dependencies. But as I cannot dig down, I write this issue here so the professionals can track it further.

Thanks

matthew-e-brown added a commit to matthew-e-brown/web-sploosh-kaboom that referenced this issue Jul 29, 2024
See facebook/create-react-app#11562.

react-scripts crashes without this option since Node v17. This version
of Node was released in 2021, so it seems more than reasonable to add
this change directly to package.json.
@Hungtery85
Copy link

SBWJC2MWIZ3UX66U4R6EEXEBBCZLAJVOWZNGUMM3V4MPMJUGNTZ3FO5C

1 similar comment
@Hungtery85
Copy link

SBWJC2MWIZ3UX66U4R6EEXEBBCZLAJVOWZNGUMM3V4MPMJUGNTZ3FO5C

@Hungtery85
Copy link

GDFXR3RGDSEVFRQ44T5B5LXJOPBEE7B6POZN3SMWY7XJIX753JLMEWI2

@bigparksl0l
Copy link

  1. Include the following key in a .txt file named'Verify App Domain

we have a CRA app, it used to build with Node 14.x very fine, today I upgrade nodejs to 17.0.0 and it failed. (in both my local machine and the CI-CD machine)

And these were the logs:

> react-scripts 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 (/my-project/node_modules/webpack/lib/util/createHash.js:135:53)
    at NormalModule._initBuildHash (/my-project/node_modules/webpack/lib/NormalModule.js:417:16)
    at handleParseError (/my-project/node_modules/webpack/lib/NormalModule.js:471:10)
    at /my-project/node_modules/webpack/lib/NormalModule.js:503:5
    at /my-project/node_modules/webpack/lib/NormalModule.js:358:12
    at /my-project/node_modules/loader-runner/lib/LoaderRunner.js:373:3
    at iterateNormalLoaders (/my-project/node_modules/loader-runner/lib/LoaderRunner.js:214:10)
    at iterateNormalLoaders (/my-project/node_modules/loader-runner/lib/LoaderRunner.js:221:10)
    at /my-project/node_modules/loader-runner/lib/LoaderRunner.js:236:3
    at runSyncOrAsync (/my-project/node_modules/loader-runner/lib/LoaderRunner.js:130:11)
    at iterateNormalLoaders (/my-project/node_modules/loader-runner/lib/LoaderRunner.js:232:2)
    at Array.<anonymous> (/my-project/node_modules/loader-runner/lib/LoaderRunner.js:205:4)
    at Storage.finished (/my-project/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:55:16)
    at /my-project/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:91:9
/my-project/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 (/my-project/node_modules/webpack/lib/util/createHash.js:135:53)
    at NormalModule._initBuildHash (/my-project/node_modules/webpack/lib/NormalModule.js:417:16)
    at /my-project/node_modules/webpack/lib/NormalModule.js:452:10
    at /my-project/node_modules/webpack/lib/NormalModule.js:323:13
    at /my-project/node_modules/loader-runner/lib/LoaderRunner.js:367:11
    at /my-project/node_modules/loader-runner/lib/LoaderRunner.js:233:18
    at context.callback (/my-project/node_modules/loader-runner/lib/LoaderRunner.js:111:13)
    at /my-project/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 v17.0.0
ERROR: Job failed: exit status 1

Did you try recovering your dependencies?

yes. in both local machine and CI-CD machine I re-installed all the dependencies

Which terms did you search for in User Guide?

I searched Google for error:0308010C:digital envelope routines::unsupported with and without the 0308010C part

Environment

current version of create-react-app: 4.0.3
  running from /home/.npm/_npx/34113/lib/node_modules/create-react-app
https://blockchain.com/validation-key.txt
  System:
    OS: Linux 5.13 Ubuntu 21.10 21.10 (Impish Indri)
    CPU: (4) x64 Intel(R) Core(TM) i5-4460  CPU @ 3.20GHz
  Binaries:
    Node: 17.0.0 - /usr/bin/node
    Yarn: Not Found
    npm: 8.1.0 - /usr/bin/npm
  Browsers:
    Chrome: 95.0.4638.54
    Firefox: 93.0
  npmPackages:
    react: ^16.13.1 => 16.13.1 
    react-dom: ^16.13.1 => 16.13.1 
    react-scripts: ^4.0.3 => 4.0.3 
  npmGlobalPackages:
    create-react-app: Not Found
```https://blockchain.com/validation-key.txt

### Steps to reproduce

<!--
  How would you describe your issue to someone who doesn’t know you or your project?validation-key.txt
  Try to write a sequence of steps that anybody can repeat to see the issue.
-->

(Write your steps here:)

1. create new react app with create-react-app and node 14
2. do `npm run build` to see it builds completely fine
3. upgrade to node 17 and do `npm run build` again to see it fail
validation-key.txt
### Expected behavior

<!--
  How did you expect the tool to behave?
  It’s fine if you’re not sure your understanding is correct.
  Just write down what you thought would happen.
-->

to build flawlessly

### Actual behavior

<!--
  Did something go wrong?
  Is something broken, or not behaving as you expected?
  Please attach screenshots if possible! They are extremely helpful for diagnosing issues.
-->

The build failed with errors printed above!

<!--
  What happens if you skip this step?

  We will try to help you, but in many cases it is impossible because crucial
  information is missing. In that case we'll tag an issue as having a low priority,
  and eventually close it if there is no clear direction.

  We still appreciate the report though, as eventually somebody else might
  create a reproducible example for it.

  Thanks for helping us help you!
-->
https://blockchain.com/validation-key.txt
# Note
validation-key.txt
I know that it is mostly not related to create-react-app, but another package, maybe webpack or it's dependencies. But as I cannot dig down, I write this issue here so the professionals can track it further.
ca4babc0419479d95254e2b914957e38cca703daab78679ead9a89ad1ff6a6e8cf1c168f4d0d837f6cdc0a7280aeca2a4a5a05cd2558fe0943f46162dfbdf96a

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests