rustwasm / book

The Rust and WebAssembly Book
https://rustwasm.github.io/docs/book/
MIT License
1.75k stars 211 forks source link

[4.2] Serving Locally fails #290

Open crcdng opened 1 year ago

crcdng commented 1 year ago

Describe the bug

"Serving Locally" fails with this error

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

(node:63214) [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 /Users/m/root/dev/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:140:10)
    at module.exports (/Users/m/root/dev/wasm/wasm-game-of-life/www/node_modules/webpack/lib/util/createHash.js:135:53)
    at NormalModule._initBuildHash (/Users/m/root/dev/wasm/wasm-game-of-life/www/node_modules/webpack/lib/NormalModule.js:417:16)
    at handleParseError (/Users/m/root/dev/wasm/wasm-game-of-life/www/node_modules/webpack/lib/NormalModule.js:471:10)
    at /Users/m/root/dev/wasm/wasm-game-of-life/www/node_modules/webpack/lib/NormalModule.js:503:5
    at /Users/m/root/dev/wasm/wasm-game-of-life/www/node_modules/webpack/lib/NormalModule.js:358:12
    at /Users/m/root/dev/wasm/wasm-game-of-life/www/node_modules/loader-runner/lib/LoaderRunner.js:373:3
    at iterateNormalLoaders (/Users/m/root/dev/wasm/wasm-game-of-life/www/node_modules/loader-runner/lib/LoaderRunner.js:214:10)
    at Array.<anonymous> (/Users/m/root/dev/wasm/wasm-game-of-life/www/node_modules/loader-runner/lib/LoaderRunner.js:205:4)
    at Storage.finished (/Users/m/root/dev/wasm/wasm-game-of-life/www/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:43:16)
    at /Users/m/root/dev/wasm/wasm-game-of-life/www/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:79:9
    at /Users/m/root/dev/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 v19.5.0

To Reproduce

Follow the steps in the book up to 4.2 "Serving Locally" on page https://rustwasm.github.io/docs/book/game-of-life/hello-world.html

Expected behavior The local dev server should start and serve the page.

CHATALOT1 commented 1 year ago

I am also experiencing this issue (linux). Limited research makes me think it could be openssl related.

OpenSSL Version: 3.0.8 Rust Version: 1.67.1 npm version: 8.19.2 node version: 19.7.0

Any help is appreciated

nik0sc commented 1 year ago

This was mentioned previously in #279 and #273. Some ways to work around it are to either:

  1. add NODE_OPTIONS=--openssl-legacy-provider to your scripts.start in package.json
  2. downgrade to node v16 (using a tool like nvm)
  3. patch your www/package.json and www/webpack.config.js with the versions from from rustwasm/create-wasm-app#207

FWIW I think the "right" way to fix it is solution 3. Could someone from @rustwasm approve that PR please?

Gers2017 commented 1 year ago

This was mentioned previously in #279 and #273. Some ways to work around it are to either:

1. add `NODE_OPTIONS=--openssl-legacy-provider` to your `scripts.start` in `package.json`

2. downgrade to node v16 (using a tool like [nvm](https://github.com/nvm-sh/nvm))

3. patch your `www/package.json` and `www/webpack.config.js` with the versions from from [Updated webpack dependencies and allowed web assembly in webpack export create-wasm-app#207](https://github.com/rustwasm/create-wasm-app/pull/207)

FWIW I think the "right" way to fix it is solution 3. Could someone from @rustwasm approve that PR please?

Thank you! This workaround worked for me 👍