scalacenter / scalajs-bundler

https://scalacenter.github.io/scalajs-bundler
Other
237 stars 101 forks source link

digital envelope routines::unsupported on node versions > 16 #438

Closed LeifW closed 1 year ago

LeifW commented 2 years ago
[info] Writing scalajs.webpack.config.js
[info] Bundling the application with its NPM dependencies
[error] node:internal/crypto/hash:67
[error]   this[kHandle] = new _Hash(algorithm, xofLen);
[error]                   ^
[error] Error: error:0308010C:digital envelope routines::unsupported
[error]     at new Hash (node:internal/crypto/hash:67:19)
[error]     at Object.createHash (node:crypto:133:10)
...[stacktrace truncated]...

There's an upstream ticket for this: https://github.com/webpack/webpack/issues/14532 that suggests invoking node with --openssl-legacy-provider. Indeed, adding webpackNodeArgs := Seq("--openssl-legacy-provider") to the build.sbt gets past this on Node 19. However, then users running node 16 get node: bad option: --openssl-legacy-provider. Is there a way to support both?

LeifW commented 2 years ago

Could maybe test the node version (> 16) and conditionally set that arg?

mathieuleclaire commented 1 year ago

Hi @LeifW, the webpackNodeArgs := Seq("--openssl-legacy-provider") trick and setting node to v18.12.1 fixes the problem for me.

LeifW commented 1 year ago

@mathieuleclaire Yes, that fixes this to work with node versions linked against openssl 3, but then other versions fail with: node: bad option: --openssl-legacy-provider..