rustwasm / book

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

Cant run command npm run start from the www folder(following the book) #301

Open lucitang opened 1 year ago

lucitang commented 1 year ago

when i run npm run start from the www folder in the project i get an error:

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 (C:\Users\Sarang Dutta\Documents\rust_projects\wasm-game-of-life\www\node_modules\webpack\lib\util\createHash.js:135:53)
    at NormalModule._initBuildHash (C:\Users\Sarang Dutta\Documents\rust_projects\wasm-game-of-life\www\node_modules\webpack\lib\NormalModule.js:417:16)
    at handleParseError (C:\Users\Sarang Dutta\Documents\rust_projects\wasm-game-of-life\www\node_modules\webpack\lib\NormalModule.js:471:10)
    at C:\Users\Sarang Dutta\Documents\rust_projects\wasm-game-of-life\www\node_modules\webpack\lib\NormalModule.js:503:5
    at C:\Users\Sarang Dutta\Documents\rust_projects\wasm-game-of-life\www\node_modules\webpack\lib\NormalModule.js:358:12
    at C:\Users\Sarang Dutta\Documents\rust_projects\wasm-game-of-life\www\node_modules\loader-runner\lib\LoaderRunner.js:373:3
    at iterateNormalLoaders (C:\Users\Sarang Dutta\Documents\rust_projects\wasm-game-of-life\www\node_modules\loader-runner\lib\LoaderRunner.js:214:10)
    at Array.<anonymous> (C:\Users\Sarang Dutta\Documents\rust_projects\wasm-game-of-life\www\node_modules\loader-runner\lib\LoaderRunner.js:205:4)
    at Storage.finished (C:\Users\Sarang Dutta\Documents\rust_projects\wasm-game-of-life\www\node_modules\enhanced-resolve\lib\CachedInputFileSystem.js:43:16)
    at C:\Users\Sarang Dutta\Documents\rust_projects\wasm-game-of-life\www\node_modules\enhanced-resolve\lib\CachedInputFileSystem.js:79:9
    at C:\Users\Sarang Dutta\Documents\rust_projects\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

rustc version: 1.71.0 npm version: 9.8.1

kaubu commented 1 year ago

Yep this happened to me too, I fixed it by setting the NODE_OPTIONS environmental variable to --openssl-legacy-provider

I don't have high hopes that this will be added in the book though, since it hasn't been updated since January 2021

asasine commented 7 months ago

I mitigated this with the same solution (NODE_OPTIONS to --openssl-legacy-provider). You can modify the generated package.json, you don't have to modify your environment.

  1. In the www directory: npm install --save-dev cross-env
  2. Modify the start script to: cross-env NODE_OPTIONS='--openssl-legacy-provider' webpack-dev-server
  3. Run: npm run start
paphopsaw commented 6 months ago

After I ran npm install I ran npm update and it worked fine. I guess it has something to do with outdated dependencies that npm init wasm-app provides.

https://github.com/rustwasm/create-wasm-app/issues/206

glennDittmann commented 6 months ago

There is a solution here: https://github.com/rustwasm/rust-webpack-template/issues/184

@paphopsaw This also worked for me, and is more coherent!