-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Description
Description
Running wp-scripts build to build a block results in this error:
Error: error:0308010C:digital envelope routines::unsupported
at new Hash (node:internal/crypto/hash:67:19)
at createHash (node:crypto:130:10)
at DependencyExtractionWebpackPlugin.addAssets (C:\Users\FramePush\Projects\Website\websitedev\generic-grid-layouts\node_modules\@wordpress\dependency-extraction-webpack-plugin\lib\index.js:200:19)
at C:\Users\FramePush\Projects\Website\websitedev\generic-grid-layouts\node_modules\@wordpress\dependency-extraction-webpack-plugin\lib\index.js:129:18
at fn (C:\Users\FramePush\Projects\Website\websitedev\generic-grid-layouts\node_modules\webpack\lib\Compilation.js:476:10)
at Hook.eval [as callAsync] (eval at create (C:\Users\FramePush\Projects\Website\websitedev\generic-grid-layouts\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:38:1)
at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (C:\Users\FramePush\Projects\Website\websitedev\generic-grid-layouts\node_modules\tapable\lib\Hook.js:18:14)
at cont (C:\Users\FramePush\Projects\Website\websitedev\generic-grid-layouts\node_modules\webpack\lib\Compilation.js:3052:34)
at C:\Users\FramePush\Projects\Website\websitedev\generic-grid-layouts\node_modules\webpack\lib\Compilation.js:3100:10
at symbolIterator (C:\Users\FramePush\Projects\Website\websitedev\generic-grid-layouts\node_modules\neo-async\async.js:3485:9)
The culprit is trying to use md4 hash:
| contentHash: createHash( 'md4' ) |
Node v17 upgrades OpenSSL to 3.0, which moved md4 hash to the legacy provider. i.e. md4 is disabled by default.
webpack solved their issue by proving an md4 implementation. See webpack/webpack#14532. But the fix here could be as simple as switching to one of the hashes in the default provider, like md5. See https://wiki.openssl.org/index.php/OpenSSL_3.0#Provider_implemented_digests What is the significance of using md4?
A workaround with security implications as discussed in the webpack issue is to export NODE_OPTIONS=--openssl-legacy-provider before invoking node
Step-by-step reproduction instructions
Install Node version 17
Invoke wp-scripts build on a block plugin
Screenshots, screen recording, code snippet
No response
Environment info
Node 17.1.0
@wordpress/scripts 19.1.0
Please confirm that you have searched existing issues in the repo.
Yes
Please confirm that you have tested with all plugins deactivated except Gutenberg.
Yes