error:0308010C:digital envelope routines::unsupported when running webpack via node 17.1.0

webpack ^5.64.3
upgraded to Node 17.1.0

This thread at the very end says to just use the latest version of webpack. I did that, still same error.

Also tried adding export NODE_OPTIONS=--openssl-legacy-provider to the top of my ~/.zshrc, then sourced it, but no luck.

now when I run webpack, I get this:

yarn run v1.22.17
$ yarn lint && yarn copyData && yarn compile-server && yarn start-static-server & node_modules/.bin/webpack-dev-server -d --watch
$ eslint --fix --quiet --ext src/**/*.ts[x]
$ yarn make-data-directory && cp ../server/data/companies.json ../../dist/server/data && cp ../server/data/countries.json ../../dist/server/data
[HPM] Proxy created: /api  ->  http://localhost:8000
[HPM] Subscribed to http-proxy events:  [ 'error', 'close' ]
[HPM] Proxy created: /graphql  ->  http://localhost:7000
[HPM] Subscribed to http-proxy events:  [ 'error', 'close' ]
ℹ 「wds」: Project is running at http://localhost:8080/
ℹ 「wds」: webpack output is served from /
ℹ 「wds」: Content not from webpack is served from /Users/daveschinkel/code/projects/we-do-tdd/src/client
ℹ 「wds」: 404s will fallback to /
$ mkdir -p ../../dist/server/data
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:130:10)
    at module.exports (/Users/daveschinkel/code/projects/we-do-tdd/src/client/node_modules/webpack/lib/util/createHash.js:135:53)
    at NormalModule._initBuildHash (/Users/daveschinkel/code/projects/we-do-tdd/src/client/node_modules/webpack/lib/NormalModule.js:417:16)
    at handleParseError (/Users/daveschinkel/code/projects/we-do-tdd/src/client/node_modules/webpack/lib/NormalModule.js:471:10)
    at /Users/daveschinkel/code/projects/we-do-tdd/src/client/node_modules/webpack/lib/NormalModule.js:503:5
    at /Users/daveschinkel/code/projects/we-do-tdd/src/client/node_modules/webpack/lib/NormalModule.js:358:12
    at /Users/daveschinkel/code/projects/we-do-tdd/src/client/node_modules/loader-runner/lib/LoaderRunner.js:373:3
    at iterateNormalLoaders (/Users/daveschinkel/code/projects/we-do-tdd/src/client/node_modules/loader-runner/lib/LoaderRunner.js:214:10)
    at Array.<anonymous> (/Users/daveschinkel/code/projects/we-do-tdd/src/client/node_modules/loader-runner/lib/LoaderRunner.js:205:4)
    at Storage.finished (/Users/daveschinkel/code/projects/we-do-tdd/src/client/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:55:16)
    at /Users/daveschinkel/code/projects/we-do-tdd/src/client/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:91:9
    at /Users/daveschinkel/code/projects/we-do-tdd/src/client/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 v17.1.0
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
$ node_modules/.bin/tsc -b ../server/
$ node --optimize_for_size --trace-warnings --experimental-json-modules --no-warnings ../../dist/server/server.js
node:internal/errors:464
    ErrorCaptureStackTrace(err);
    ^

TypeError [ERR_IMPORT_ASSERTION_TYPE_MISSING]: Module "file:///Users/daveschinkel/code/projects/we-do-tdd/dist/server/data/countries.json" needs an import assertion of type "json"
    at new NodeError (node:internal/errors:371:5)
    at validateAssertions (node:internal/modules/esm/assert:74:15)
    at defaultLoad (node:internal/modules/esm/load:25:3)
    at ESMLoader.load (node:internal/modules/esm/loader:353:26)
    at ESMLoader.moduleProvider (node:internal/modules/esm/loader:274:58)
    at new ModuleJob (node:internal/modules/esm/module_job:66:26)
    at ESMLoader.#createModuleJob (node:internal/modules/esm/loader:291:17)
    at ESMLoader.getModuleJob (node:internal/modules/esm/loader:255:34)
    at async ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:81:21)
    at async Promise.all (index 1) {
  code: 'ERR_IMPORT_ASSERTION_TYPE_MISSING'
}

Node.js v17.1.0
error Command failed with exit code 1.

1 thought on “error:0308010C:digital envelope routines::unsupported when running webpack via node 17.1.0

Comments are closed.