Movatterモバイル変換


[0]ホーム

URL:


Skip to content
DEV Community
Log in Create account

DEV Community

Paul Yu
Paul Yu

Posted on • Originally published atpaulyu.dev on

     

Fixing a NodeJS Digital Envelope Routines Error

In my journey to learn Rust, I've decided to pick up this book called"Practical Rust Web Projects" by Shing Lyu.

In the last chapter, you walk through an example of packaging a WebAssembly module usingwasm-pack and using the .wasm binary in a NodeJS application. On the step where I needed to compile the application, I ran into the following error:

$npm run build> create-wasm-app@0.1.0 build> webpack--config webpack.config.jsnode:internal/crypto/hash:71  this[kHandle]= new _Hash(algorithm, xofLen);                  ^Error: error:0308010C:digital envelope routines::unsupported    at new Hash(node:internal/crypto/hash:71:19)    at Object.createHash(node:crypto:133:10)    at module.exports(/Users/paul/repos/Apress/practical-rust-web-projects/Ch06/hello-wasm/client/node_modules/webpack/lib/util/createHash.js:135:53)    at NormalModule._initBuildHash(/Users/paul/repos/Apress/practical-rust-web-projects/Ch06/hello-wasm/client/node_modules/webpack/lib/NormalModule.js:417:16)    at handleParseError(/Users/paul/repos/Apress/practical-rust-web-projects/Ch06/hello-wasm/client/node_modules/webpack/lib/NormalModule.js:471:10)    at /Users/paul/repos/Apress/practical-rust-web-projects/Ch06/hello-wasm/client/node_modules/webpack/lib/NormalModule.js:503:5    at /Users/paul/repos/Apress/practical-rust-web-projects/Ch06/hello-wasm/client/node_modules/webpack/lib/NormalModule.js:358:12    at /Users/paul/repos/Apress/practical-rust-web-projects/Ch06/hello-wasm/client/node_modules/loader-runner/lib/LoaderRunner.js:373:3    at iterateNormalLoaders(/Users/paul/repos/Apress/practical-rust-web-projects/Ch06/hello-wasm/client/node_modules/loader-runner/lib/LoaderRunner.js:214:10)    at Array.<anonymous>(/Users/paul/repos/Apress/practical-rust-web-projects/Ch06/hello-wasm/client/node_modules/loader-runner/lib/LoaderRunner.js:205:4)    at Storage.finished(/Users/paul/repos/Apress/practical-rust-web-projects/Ch06/hello-wasm/client/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:43:16)    at /Users/paul/repos/Apress/practical-rust-web-projects/Ch06/hello-wasm/client/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:79:9    at /Users/paul/repos/Apress/practical-rust-web-projects/Ch06/hello-wasm/client/node_modules/graceful-fs/graceful-fs.js:78: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'}Node.js v18.7.0
Enter fullscreen modeExit fullscreen mode

After a bit of Googling, I ran across someone suggesting to run the following command:

$exportNODE_OPTIONS=--openssl-legacy-provider
Enter fullscreen modeExit fullscreen mode

Then run the build command again, and it compiled 🎉

$npm run build> create-wasm-app@0.1.0 build> webpack--config webpack.config.jsHash: 1707689247fe60c788afVersion: webpack 4.42.0Time: 67msBuilt at: 11/08/2022 7:50:56 PM                           Asset       Size  Chunks                         Chunk Names                  0.bootstrap.js   5.31 KiB       0[emitted]7e852f2346d8cc54b57a.module.wasm  296 bytes       0[emitted][immutable]                    bootstrap.js     11 KiB    main[emitted]              main                      index.html  297 bytes[emitted]Entrypoint main= bootstrap.js[../pkg/hello_wasm.js] 81 bytes{0}[built][../pkg/hello_wasm_bg.js] 784 bytes{0}[built][../pkg/hello_wasm_bg.wasm] 270 bytes{0}[built][./bootstrap.js] 279 bytes{main}[built][./index.js] 51 bytes{0}[built][./node_modules/webpack/buildin/harmony-module.js](webpack)/buildin/harmony-module.js 573 bytes{0}[built]
Enter fullscreen modeExit fullscreen mode

This is definitely not the proper fix in a production scenario, but good enough to get me through the example 😉

Cheers!

Top comments(3)

Subscribe
pic
Create template

Templates let you quickly answer FAQs or store snippets for re-use.

Dismiss
CollapseExpand
 
aqueous911 profile image
sammael
Full-stack Web Dev | GGMU
  • Education
    Delta State University, Oleh
  • Work
    Intern at Smartware Innovation
  • Joined
• Edited on• Edited

I'd like to know what the proper fix in a production scenario would be. I encountered this problem while working with an express app in NodeJS.

CollapseExpand
 
pauldotyu profile image
Paul Yu
Cloud Native Developer Advocate @ Microsoft
  • Location
    Los Angeles, CA
  • Joined

I have not tested this but seems like moving to LTS version of NodeJS or upgrading react-scripts to version 5.x or higher.freecodecamp.org/news/error-error-...

CollapseExpand
 
lancelet profile image
Jonathan Merritt
  • Joined
• Edited on• Edited

This new PR worked for me:github.com/rustwasm/create-wasm-ap...
(In the context of learning Rust + wasm.)

I made the changes manually, then rannpm install, after whichnpm run start worked as expected.

Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment'spermalink.

For further actions, you may consider blocking this person and/orreporting abuse

Cloud Native Developer Advocate @ Microsoft
  • Location
    Los Angeles, CA
  • Joined

Trending onDEV CommunityHot

DEV Community

We're a place where coders share, stay up-to-date and grow their careers.

Log in Create account

[8]ページ先頭

©2009-2025 Movatter.jp