question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Node 17: ERR_OSSL_EVP_UNSUPPORTED

See original GitHub issue

Describe the bug Webpack seems to have an issue with Node 17.x, specifically OpenSSL 3 (cf. this issue).

To Reproduce

  1. have Node 17.x installed
  2. create a new Vue 2.x project
  3. vue add electron-builder
  4. start the project in development mode (e.g., vue-cli-service electron:serve)

The exception will be along these lines:

Starting type checking service...
Using 1 worker with 2048MB memory limit
10% building 2/5 modules 3 active ...mProjects\projectName\node_modules\ts-loader\index.js??ref--13-1!C:\Users\user\WebstormProjects\projectName\node_modules\eslint-loader\index.js??ref--12-0!C:\Users\user\WebstormProjects\projectName\src\main.tsE
rror: 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 (C:\Users\user\WebstormProjects\projectName\node_modules\webpack\lib\util\createHash.js:135:53)
    at NormalModule._initBuildHash (C:\Users\user\WebstormProjects\projectName\node_modules\webpack\lib\NormalModule.js:417:16)
    at handleParseError (C:\Users\user\WebstormProjects\projectName\node_modules\webpack\lib\NormalModule.js:471:10)
    at C:\Users\user\WebstormProjects\projectName\node_modules\webpack\lib\NormalModule.js:503:5
    at C:\Users\user\WebstormProjects\projectName\node_modules\webpack\lib\NormalModule.js:358:12
    at C:\Users\user\WebstormProjects\projectName\node_modules\loader-runner\lib\LoaderRunner.js:373:3
    at iterateNormalLoaders (C:\Users\user\WebstormProjects\projectName\node_modules\loader-runner\lib\LoaderRunner.js:214:10)
    at iterateNormalLoaders (C:\Users\user\WebstormProjects\projectName\node_modules\loader-runner\lib\LoaderRunner.js:221:10)
    at C:\Users\user\WebstormProjects\projectName\node_modules\loader-runner\lib\LoaderRunner.js:236:3
    at runSyncOrAsync (C:\Users\user\WebstormProjects\projectName\node_modules\loader-runner\lib\LoaderRunner.js:130:11)
    at iterateNormalLoaders (C:\Users\user\WebstormProjects\projectName\node_modules\loader-runner\lib\LoaderRunner.js:232:2)
    at Array.<anonymous> (C:\Users\user\WebstormProjects\projectName\node_modules\loader-runner\lib\LoaderRunner.js:205:4)
    at Storage.finished (C:\Users\user\WebstormProjects\projectName\node_modules\enhanced-resolve\lib\CachedInputFileSystem.js:55:16)
    at C:\Users\user\WebstormProjects\projectName\node_modules\enhanced-resolve\lib\CachedInputFileSystem.js:91:9
node:internal/crypto/hash:67
  this[kHandle] = new _Hash(algorithm, xofLen);
                  ^

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 (C:\Users\user\WebstormProjects\projectName\node_modules\webpack\lib\util\createHash.js:135:53)
    at NormalModule._initBuildHash (C:\Users\user\WebstormProjects\projectName\node_modules\webpack\lib\NormalModule.js:417:16)
    at handleParseError (C:\Users\user\WebstormProjects\projectName\node_modules\webpack\lib\NormalModule.js:471:10)
    at C:\Users\user\WebstormProjects\projectName\node_modules\webpack\lib\NormalModule.js:503:5
    at C:\Users\user\WebstormProjects\projectName\node_modules\webpack\lib\NormalModule.js:358:12
    at C:\Users\user\WebstormProjects\projectName\node_modules\loader-runner\lib\LoaderRunner.js:373:3
    at iterateNormalLoaders (C:\Users\user\WebstormProjects\projectName\node_modules\loader-runner\lib\LoaderRunner.js:214:10)
    at Array.<anonymous> (C:\Users\user\WebstormProjects\projectName\node_modules\loader-runner\lib\LoaderRunner.js:205:4)
    at Storage.finished (C:\Users\user\WebstormProjects\projectName\node_modules\enhanced-resolve\lib\CachedInputFileSystem.js:55:16)
    at C:\Users\user\WebstormProjects\projectName\node_modules\enhanced-resolve\lib\CachedInputFileSystem.js:91:9
    at C:\Users\user\WebstormProjects\projectName\node_modules\graceful-fs\graceful-fs.js:123:16
    at FSReqCallback.readFileAfterClose [as oncomplete] (node:internal/fs/read_file_context:68:3) {
  opensslErrorStack: [ 'error:03000086:digital envelope routines::initialization error' ],
  library: 'digital envelope routines',
  reason: 'unsupported',
  code: 'ERR_OSSL_EVP_UNSUPPORTED'
}

This problem is not exclusive to the electron-builder plugin as the root cause seems to be compatibility issues between webpack and NodeJS 17.x. However, I have found no way to include the suggested workaround of adding --openssl-legacy-provider to my NODE_OPTIONS as Electron doesn’t like it:

 DONE  Compiled successfully in 2269ms                                                                                                                                                                                                           10:05:12

  File                      Size                                                                                                         Gzipped

  dist_electron\index.js    810.03 KiB                                                                                                   177.14 KiB

  Images and other types of assets omitted.

 INFO  Launching Electron...
electron: --openssl-legacy-provider is not allowed in NODE_OPTIONS

Process finished with exit code 0

I’d appreciate any guidance on the subject. I’d personally like to avoid downgrading to Node 16.x, but if that’s the only recourse, that’s what I shall do 😃

Expected behavior Application starts as it normally would.

Environment (please complete the following information):

  • Windows 10 x64
  • WebStorm IDE (2021.2.3)
  • NodeJS 17.0.1

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
ctroncommented, Nov 18, 2022

I don’t think the issue is with NodeJS, but with webpack using an unsupported hash algorithm. That algorithm (md4) was supported before, but no longer is. In newer webpack versions, this can be overridden: https://stackoverflow.com/a/73027407/222044

The problem is, as @mrveress alread posted, it seems to be impossible to override this setting in vue.config.js. If you however go to node_modules/vue-cli-plugin-electron-builder/node_modules/webpack/lib/util/createHash.js:135:53 and replace:

	switch (algorithm) {
		// TODO add non-cryptographic algorithm here
		case "debug":
			return new DebugHash();
		default:
-			return new BulkUpdateDecorator(require("crypto").createHash(algorithm));
+			return new BulkUpdateDecorator(require("crypto").createHash("sha1"));
	}

Then it works.

Of course this isn’t a persistent change, and will be gone with the next update of dependencies.

The question is: why doesn’t vue.config.js allow one to override the output.hashFunction setting?

0reactions
imic07commented, Nov 21, 2022

@ctron my createHash.js is here: node_modules/webpack/lib/util/createHash.js:135:53 after replace with ‘sha1’ it work well

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to fix err_ossl_evp_unsupported On NodeJs 17
If you hit an ERR_OSSL_EVP_UNSUPPORTED error in your application with Node.js 17, it's likely that your application or a module you're using ...
Read more >
Node.js 17.0.1 Gatsby error - "digital envelope routines
If you hit an ERR_OSSL_EVP_UNSUPPORTED error in your application with Node.js 17, it's likely that your application or a module you're using ...
Read more >
How To Fix ERR_OSSL_EVP_UNSUPPORTED In React JS ...
If you hit an ERR_OSSL_EVP_UNSUPPORTED error in your application with Node.js 17, it's likely that your application or a module you're using is...
Read more >
ERR_OSSL_EVP_UNSUPPORT...
The current install docs say to install node.js using nvm: nvm install stable However, ... ERR_OSSL_EVP_UNSUPPORTED Node 17 #350.
Read more >
ERR_OSSL_EVP_UNSUPPORT...
If you hit an ERR_OSSL_EVP_UNSUPPORTED error in your application with Node.js 17, it's likely that your application or a module you're using ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found