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

npm start fails with error:0308010C:digital envelope routines::unsupported #184

Open
DDR0 opened this issue Jul 2, 2022 · 6 comments
Open
Labels
bug Something isn't working

Comments

@DDR0
Copy link

DDR0 commented Jul 2, 2022

After running npm init rust-webpack sand2, I get the following unexpected error when running npm start.

> rust-webpack-template@0.1.0 start
> rimraf dist pkg && webpack-dev-server --open -d

🧐  Checking for wasm-pack...

✅  wasm-pack is installed at /home/david/.cargo/bin/wasm-pack. 

ℹ️  Compiling your crate in development mode...

ℹ 「wds」: Project is running at http://localhost:8080/
ℹ 「wds」: webpack output is served from /
ℹ 「wds」: Content not from webpack is served from /home/david/Projects/sand2/dist
ℹ 「wdm」: wait until bundle finished: /
[INFO]: Checking for the Wasm target...
[INFO]: Compiling to Wasm...
warning: Found `debug_assertions` in `target.'cfg(...)'.dependencies`. This value is not supported for selecting dependencies and will not work as expected. To learn more visit https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html#platform-specific-dependencies
   Compiling proc-macro2 v1.0.40
   Compiling unicode-ident v1.0.1
   Compiling quote v1.0.20
   Compiling log v0.4.17
   Compiling wasm-bindgen-shared v0.2.81
   Compiling syn v1.0.98
   Compiling cfg-if v1.0.0
   Compiling lazy_static v1.4.0
   Compiling bumpalo v3.10.0
   Compiling wasm-bindgen v0.2.81
   Compiling wasm-bindgen-backend v0.2.81
   Compiling wasm-bindgen-macro-support v0.2.81
   Compiling wasm-bindgen-macro v0.2.81
   Compiling js-sys v0.3.58
   Compiling console_error_panic_hook v0.1.7
   Compiling web-sys v0.3.58
   Compiling rust-webpack-template v0.1.0 (/home/david/Projects/sand2)
    Finished dev [unoptimized + debuginfo] target(s) in 12.90s
[INFO]: Installing wasm-bindgen...
[INFO]: Optional fields missing from Cargo.toml: 'repository', 'license'. These are not necessary, but recommended
[INFO]: :-) Done in 13.18s
[INFO]: :-) Your wasm pkg is ready to publish at /home/david/Projects/sand2/pkg.
✅  Your crate has been correctly compiled

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:133:10)
    at module.exports (/home/david/Projects/sand2/node_modules/webpack/lib/util/createHash.js:135:53)
    at NormalModule._initBuildHash (/home/david/Projects/sand2/node_modules/webpack/lib/NormalModule.js:417:16)
    at handleParseError (/home/david/Projects/sand2/node_modules/webpack/lib/NormalModule.js:471:10)
    at /home/david/Projects/sand2/node_modules/webpack/lib/NormalModule.js:503:5
    at /home/david/Projects/sand2/node_modules/webpack/lib/NormalModule.js:358:12
    at /home/david/Projects/sand2/node_modules/loader-runner/lib/LoaderRunner.js:373:3
    at iterateNormalLoaders (/home/david/Projects/sand2/node_modules/loader-runner/lib/LoaderRunner.js:214:10)
    at Array.<anonymous> (/home/david/Projects/sand2/node_modules/loader-runner/lib/LoaderRunner.js:205:4)
    at Storage.finished (/home/david/Projects/sand2/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:55:16)
    at /home/david/Projects/sand2/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:91:9
    at /home/david/Projects/sand2/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'
}

Node.js v18.3.0
@DDR0 DDR0 added the bug Something isn't working label Jul 2, 2022
@Hero9909
Copy link

Same here, tried on two systems.

@tomgroenwoldt
Copy link

Hey, I got rid of this error by downgrading my nodejs to v14.21.0 (nodejs-lts-fermium).

@ailonn
Copy link

ailonn commented Nov 10, 2022

hi ! I met the same error following this tutorial : https://rustwasm.github.io/docs/book/game-of-life/hello-world.html

➜  www git:(master) ✗ npm start

> create-wasm-app@0.1.0 start
> webpack-dev-server

(node:72723) [DEP0111] DeprecationWarning: Access to process.binding('http_parser') is deprecated.
(Use `node --trace-deprecation ...` to show where the warning was created)
ℹ 「wds」: Project is running at http://localhost:8080/
ℹ 「wds」: webpack output is served from /
ℹ 「wds」: Content not from webpack is served from /mnt/a53f0ac3-5681-4d20-8292-8ff20b8d0d0b/Documents/project/rust/wasm/wasm-game-of-life/www
node: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 (/mnt/a53f0ac3-5681-4d20-8292-8ff20b8d0d0b/Documents/project/rust/wasm/wasm-game-of-life/www/node_modules/webpack/lib/util/createHash.js:135:53)
    at NormalModule._initBuildHash (/mnt/a53f0ac3-5681-4d20-8292-8ff20b8d0d0b/Documents/project/rust/wasm/wasm-game-of-life/www/node_modules/webpack/lib/NormalModule.js:417:16)
    at handleParseError (/mnt/a53f0ac3-5681-4d20-8292-8ff20b8d0d0b/Documents/project/rust/wasm/wasm-game-of-life/www/node_modules/webpack/lib/NormalModule.js:471:10)
    at /mnt/a53f0ac3-5681-4d20-8292-8ff20b8d0d0b/Documents/project/rust/wasm/wasm-game-of-life/www/node_modules/webpack/lib/NormalModule.js:503:5
    at /mnt/a53f0ac3-5681-4d20-8292-8ff20b8d0d0b/Documents/project/rust/wasm/wasm-game-of-life/www/node_modules/webpack/lib/NormalModule.js:358:12
    at /mnt/a53f0ac3-5681-4d20-8292-8ff20b8d0d0b/Documents/project/rust/wasm/wasm-game-of-life/www/node_modules/loader-runner/lib/LoaderRunner.js:373:3
    at iterateNormalLoaders (/mnt/a53f0ac3-5681-4d20-8292-8ff20b8d0d0b/Documents/project/rust/wasm/wasm-game-of-life/www/node_modules/loader-runner/lib/LoaderRunner.js:214:10)
    at Array.<anonymous> (/mnt/a53f0ac3-5681-4d20-8292-8ff20b8d0d0b/Documents/project/rust/wasm/wasm-game-of-life/www/node_modules/loader-runner/lib/LoaderRunner.js:205:4)
    at Storage.finished (/mnt/a53f0ac3-5681-4d20-8292-8ff20b8d0d0b/Documents/project/rust/wasm/wasm-game-of-life/www/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:43:16)
    at /mnt/a53f0ac3-5681-4d20-8292-8ff20b8d0d0b/Documents/project/rust/wasm/wasm-game-of-life/www/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:79:9
    at /mnt/a53f0ac3-5681-4d20-8292-8ff20b8d0d0b/Documents/project/rust/wasm/wasm-game-of-life/www/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.12.1

I downgrade my nodejs to the LTS v16.18.1 (Gallium) to get rid of this error.

@pythagorean
Copy link

pythagorean commented Feb 10, 2023

Add to webpack.config.js:

const crypto = require("crypto");
const crypto_orig_createHash = crypto.createHash;
crypto.createHash = algorithm => crypto_orig_createHash(algorithm == "md4" ? "sha256" : algorithm);

This should fix the error.

@glennDittmann
Copy link

@pythagorean Thanks ! Can confirm it worked. I think this should be added to the wasm-book.

@pati08
Copy link

pati08 commented Jun 10, 2024

Is this an issue with the book, or is this something that should be changed in the template?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

8 participants
@DDR0 @Hero9909 @ailonn @pythagorean @glennDittmann @tomgroenwoldt @pati08 and others