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

nodejs 17: digital envelope routines::unsupported #14532

Closed
akornatskyy opened this issue Oct 19, 2021 · 288 comments · Fixed by #14584
Closed

nodejs 17: digital envelope routines::unsupported #14532

akornatskyy opened this issue Oct 19, 2021 · 288 comments · Fixed by #14584

Comments

@akornatskyy
Copy link

Bug report

What is the current behavior?

[webpack-cli] Error: error:0308010C:digital envelope routines::unsupported
    at new Hash (node:internal/crypto/hash:67:19)
    at Object.createHash (node:crypto:130:10)
    at BulkUpdateDecorator.hashFactory (/opt/src/node_modules/webpack/lib/util/createHash.js:155:18)
    at BulkUpdateDecorator.digest (/opt/src/node_modules/webpack/lib/util/createHash.js:80:21)
    at /opt/src/node_modules/webpack/lib/DefinePlugin.js:595:38
    at Hook.eval [as call] (eval at create (/opt/src/node_modules/tapable/lib/HookCodeFactory.js:19:10), <anonymous>:100:1)
    at Hook.CALL_DELEGATE [as _call] (/opt/src/node_modules/tapable/lib/Hook.js:14:14)
    at Compiler.newCompilation (/opt/src/node_modules/webpack/lib/Compiler.js:1053:26)
    at /opt/src/node_modules/webpack/lib/Compiler.js:1097:29
    at Hook.eval [as callAsync] (eval at create (/opt/src/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:6:1) {
  opensslErrorStack: [ 'error:03000086:digital envelope routines::initialization error' ],
  library: 'digital envelope routines',
  reason: 'unsupported',
  code: 'ERR_OSSL_EVP_UNSUPPORTED'
}

Other relevant information:
webpack version: 5.59.0
Node.js version: 17.0.0
Operating System: linux x64

@alexander-akait
Copy link
Member

alexander-akait commented Oct 19, 2021

Why do you ignore reproducible repo? What is output.hashFunction/output.hashDigest and etc? I see...

@alexander-akait
Copy link
Member

nodejs/node#40455

@akornatskyy
Copy link
Author

workaround:

export NODE_OPTIONS=--openssl-legacy-provider

@zloirock
Copy link

The same situation is also with webpack@4. I hope that it will be fixed in the legacy versions too since I'm blocked to use the actual webpack versions in legacy projects due to the requirement of the support of old NodeJS versions.

@alexander-akait
Copy link
Member

Yes, marked as critical

@sokra
Copy link
Member

sokra commented Oct 20, 2021

The same situation is also with webpack@4. I hope that it will be fixed in the legacy versions too since I'm blocked to use the actual webpack versions in legacy projects due to the requirement of the support of old NodeJS versions.

We will not update that in webpack 4.

@alexander-akait
Copy link
Member

For webpack 4 solutions:

  • export NODE_OPTIONS=--openssl-legacy-provider
  • monkey patching crypto for md4 and Node.js v17

@sokra
Copy link
Member

sokra commented Oct 20, 2021

hmm... We can't really automatically fallback to a different hashing algorithm, since this would break the determinism of builds (builds should be equal independent of node.js version).

We are planning to migrate to a different hash function anyway for webpack 6. So currently you will have to use output.hashFunction: "xxhash64" in configuration to fix that. Or --openssl-legacy-provider

Seems like the need to release a new major becomes more pressing...

@alexander-akait
Copy link
Member

alexander-akait commented Oct 20, 2021

To be honestly it is very strange from Node.js developers, no deprecation messages, they just remove it... and break a lot of packages

@MaxGraey
Copy link

MaxGraey commented Oct 20, 2021

To be honestly it is very strange from Node.js developers, no deprecation messages, they just remove it... and break a lot of packages

node.js 17 uses OpenSSL3 which have changed code for initialization context of md family (including md4):
https://wiki.openssl.org/index.php/OpenSSL_3.0#Upgrading_to_OpenSSL_3.0_from_OpenSSL_1.0.2

But I agree that node.js could have warned you in advance, given that you are one of the biggest consumers.

@FSM1
Copy link

FSM1 commented Oct 22, 2021

workaround:

export NODE_OPTIONS=--openssl-legacy-provider

where should this be added?

@akornatskyy
Copy link
Author

akornatskyy commented Oct 22, 2021

@FSM1 : if you use bash or related just execute that before you work with webpack.

shinyjohn0401 pushed a commit to shinyjohn0401/react-cool-inview that referenced this issue Jan 22, 2024
With Node 17 we are having the following message: `Error:
error:0308010C:digital envelope routines::unsupported`. Downgrading to Node 16
seems better than forcing `export NODE_OPTIONS=--openssl-legacy-provider` and
possibly running with [known insecure
SSL](https://www.openssl.org/docs/manmaster/man7/OSSL_PROVIDER-legacy.html).

Reference:
webpack/webpack#14532 (comment)
@typedef24
Copy link

workaround:

export NODE_OPTIONS=--openssl-legacy-provider

Thanks but I'm a little confused please. Where do I put this piece of code?

@typedef24
Copy link

workaround:

export NODE_OPTIONS=--openssl-legacy-provider

Where do I put this piece of code please? I'm a little confused

@wtfiwtz
Copy link

wtfiwtz commented Jan 27, 2024

@typedef24 run that before running node. You are setting an environment variable.
I assume Linux or MacOS, not Windows.

@aladdin-add
Copy link
Contributor

aladdin-add commented Jan 29, 2024

cross-env is most used for this.

  1. install cross-env
npm install cross-env
  1. put it in the scripts in package.json
{
"scripts": {
  "build": "cross-env NODE_OPTIONS=--openssl-legacy-provider webpack ...."
}
}

works for all os! 🎉

LucSPI added a commit to LucSPI/chrome-extension-typescript that referenced this issue Feb 12, 2024
When using latest node, webpack produces an error,

Error: error:0308010C:digital envelope routines::unsupported

webpack/webpack#14532

This is due to the webpack version being 5.53.0 when running npm install.  The error is fixed in 5.61.0 by the following merged pull request,

webpack/webpack#14584

https://github.com/webpack/webpack/releases/tag/v5.61.0

When I set 5.61.0 as the minimum I now get 5.72.0 version which is latest. Build completes without error.
cubeghost added a commit to cubeghost/tagreplacer that referenced this issue Feb 19, 2024
@AntoJelastin
Copy link

Worked on angular

export NODE_OPTIONS=--openssl-legacy-provider

Offroaders123 added a commit to Offroaders123/ConvertJavaTextureToBedrock that referenced this issue Mar 15, 2024
Looks like it was a few different issues. The native build compilation error with Sharp was as a dependency of favicons-webpack-plugin, which looks to be something like PWA support. I can add that on my own as a standalone thing later on, so I disabled that for the time being.

Once that was fixed, Webpack wouldn't run properly, and it turned out to be what seems like a deprecated Node feature of SSL which was removed, so you have to pass a specific flag to Node to enable it again.

Going to try seeing how the built version of the site looks, and I want to try moving things over to Vite too, for modern bundling tech.

webpack/webpack#14532
https://unix.stackexchange.com/questions/381902/permission-denied-when-we-use-npm-start-using-webpack
https://stackoverflow.com/questions/1158091/defining-a-variable-with-or-without-export
https://dev.to/wojtekmaj/migrating-your-react-app-from-webpack-to-vite-inp
bkeepers added a commit to chordbook/chorpro-parser that referenced this issue Mar 15, 2024
jrmora pushed a commit to chordproject/chorpro-parser that referenced this issue Mar 15, 2024
* Update to latest webpack to fix issue in Node >=17

cc webpack/webpack#14532

* Configure CI with GitHub Actions

* Rename files to fix case-sensitive filename issue
@luismiguelro
Copy link

I did below and it worked:
replace "start": "react-scripts start" by "start": "react-scripts --openssl-legacy-provider start"
replace "build": "react-scripts build" by "build": "react-scripts --openssl-legacy-provider build"

moormaster added a commit to moormaster/vuepress-test-site that referenced this issue Apr 20, 2024
@ubaid858
Copy link

workaround:

export NODE_OPTIONS=--openssl-legacy-provider

How to use at React native?

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