PacktPublishing / Game-Development-with-Rust-and-WebAssembly

Game Development with Rust and WebAssembly, Published by Packt
MIT License
205 stars 33 forks source link

Node.js v17 or later requires additional options #19

Open tkhm opened 1 year ago

tkhm commented 1 year ago

Summary

If you use Node.js v17 or later, you'll face the ERR_OSSL_EVP_UNSUPPORTED when you run npm run start. And the workaround is the following

export NODE_OPTIONS=--openssl-legacy-provider

It would be helpful if the book mention this point in some ways.

Detail

I just started to read the book and faced an issue on chap 1's Run the server step.

Here is the error message.

node:internal/crypto/hash:69
  this[kHandle] = new _Hash(algorithm, xofLen);
                  ^

Error: error:0308010C:digital envelope routines::unsupported
    at new Hash (node:internal/crypto/hash:69:19)
    at Object.createHash (node:crypto:138:10)
    at module.exports (/Users/tkhm/git/walk-the-dog/node_modules/webpack/lib/util/createHash.js:135:53)
    at NormalModule._initBuildHash (/Users/tkhm/git/walk-the-dog/node_modules/webpack/lib/NormalModule.js:417:16)
    at handleParseError (/Users/tkhm/git/walk-the-dog/node_modules/webpack/lib/NormalModule.js:471:10)
    at /Users/tkhm/git/walk-the-dog/node_modules/webpack/lib/NormalModule.js:503:5
    at /Users/tkhm/git/walk-the-dog/node_modules/webpack/lib/NormalModule.js:358:12
    at /Users/tkhm/git/walk-the-dog/node_modules/loader-runner/lib/LoaderRunner.js:373:3
    at iterateNormalLoaders (/Users/tkhm/git/walk-the-dog/node_modules/loader-runner/lib/LoaderRunner.js:214:10)
    at Array.<anonymous> (/Users/tkhm/git/walk-the-dog/node_modules/loader-runner/lib/LoaderRunner.js:205:4)
    at Storage.finished (/Users/tkhm/git/walk-the-dog/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:55:16)
    at /Users/tkhm/git/walk-the-dog/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:91:9
    at /Users/tkhm/git/walk-the-dog/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'
}

And looks it is known issue.

ref https://github.com/webpack/webpack/issues/14532#issuecomment-947012063

And this StackOverflow's answers are well described how we can avoid this issue. (and downgrading to v16 or use legacy provider are not the best solution for the long term though)

node.js - Error message "error:0308010C:digital envelope routines::unsupported" - Stack Overflow https://stackoverflow.com/questions/69692842/error-message-error0308010cdigital-envelope-routinesunsupported

markgong commented 2 months ago

it is because your node version is too height. if your node version is 1.18, please use 1.16 instead and try if it is ok

tkhm commented 2 months ago

it is because your node version is too height. if your node version is 1.18, please use 1.16 instead and try if it is ok

Thanks for your comment but as I shared Stack Overflow link with my comment, we know it is one of the options but not the best. And already v16 support was end in the last year.

In addition, looks still this repo’s document is maintained by the author(at least it was updated in the last year), so then note this for the reader in some ways, it would be very helpful in my opinion. (That’s why I issued this as well)

paytonrules commented 2 months ago

Sorry for the long delay - I never saw this when you first reported it for some reason but I can definitely update the README with this info.