ipfs-blog icon indicating copy to clipboard operation
ipfs-blog copied to clipboard

Build errors

Open 2color opened this issue 3 years ago • 1 comments

In recent PRs we got the follwing error:

12:53:21 PM 10/27/2022: ^
12:53:21 PM 10/27/2022: Error: error:0308010C:digital envelope routines::unsupported
12:53:21 PM 10/27/2022: at new Hash (node:internal/crypto/hash:71:19)
12:53:21 PM 10/27/2022: at Object.createHash (node:crypto:133:10)
12:53:21 PM 10/27/2022: at module.exports (/workspace/node_modules/webpack/lib/util/createHash.js:135:53)
12:53:21 PM 10/27/2022: at NormalModule._initBuildHash (/workspace/node_modules/webpack/lib/NormalModule.js:417:16)
12:53:21 PM 10/27/2022: at handleParseError (/workspace/node_modules/webpack/lib/NormalModule.js:471:10)
12:53:21 PM 10/27/2022: at /workspace/node_modules/webpack/lib/NormalModule.js:503:5
12:53:21 PM 10/27/2022: at /workspace/node_modules/webpack/lib/NormalModule.js:358:12
12:53:21 PM 10/27/2022: at /workspace/node_modules/loader-runner/lib/LoaderRunner.js:373:3
12:53:21 PM 10/27/2022: at iterateNormalLoaders (/workspace/node_modules/loader-runner/lib/LoaderRunner.js:214:10)
12:53:21 PM 10/27/2022: at iterateNormalLoaders (/workspace/node_modules/loader-runner/lib/LoaderRunner.js:221:10)
12:53:21 PM 10/27/2022: at /workspace/node_modules/loader-runner/lib/LoaderRunner.js:236:3
12:53:21 PM 10/27/2022: at context.callback (/workspace/node_modules/loader-runner/lib/LoaderRunner.js:111:13)
12:53:21 PM 10/27/2022: at /workspace/node_modules/cache-loader/dist/index.js:134:7
12:53:21 PM 10/27/2022: at /workspace/node_modules/graceful-fs/graceful-fs.js:61:14
12:53:21 PM 10/27/2022: at FSReqCallback.oncomplete (node:fs:197:23) {
12:53:21 PM 10/27/2022: opensslErrorStack: [ 'error:03000086:digital envelope routines::initialization error' ],
12:53:21 PM 10/27/2022: library: 'digital envelope routines',
12:53:21 PM 10/27/2022: reason: 'unsupported',
12:53:21 PM 10/27/2022: code: 'ERR_OSSL_EVP_UNSUPPORTED'
12:53:21 PM 10/27/2022: }
12:53:21 PM 10/27/2022: Node.js v18.12.0
12:53:45 PM 10/27/2022: Error occured during the build.

I haven't been able to find the exact root cause, but since we were using the node:lts Docker build image, this error may stem from a recent version bump of node.

This likely stems from Webpack using a specific hash function that is linked to OpenSSL.

I was able to resolve this by adding the following ENV var to the build:

NODE_OPTIONS=--openssl-legacy-provider

We should investigate how to better resolve this. Perhaps it's from some outdated dependencies in this repo that are using an old version of Webpack.

2color avatar Oct 27 '22 16:10 2color

I was stuck on this issue too. I'm running the latest nodejs version (as of this moment, 20.8.0) and it gives me:

ℹ 「wds」: Project is running at http://0.0.0.0:8081/
ℹ 「wds」: webpack output is served from /
ℹ 「wds」: Content not from webpack is served from /home/mark/GitProjects/ipfs-blog/src/.vuepress/public
ℹ 「wds」: 404s will fallback to /index.html
node:internal/crypto/hash:68
  this[kHandle] = new _Hash(algorithm, xofLen);
                  ^

Error: error:0308010C:digital envelope routines::unsupported
    at new Hash (node:internal/crypto/hash:68:19)
    at Object.createHash (node:crypto:138:10)
    at module.exports (/home/mark/GitProjects/ipfs-blog/node_modules/webpack/lib/util/createHash.js:135:53)
    at NormalModule._initBuildHash (/home/mark/GitProjects/ipfs-blog/node_modules/webpack/lib/NormalModule.js:417:16)
    at handleParseError (/home/mark/GitProjects/ipfs-blog/node_modules/webpack/lib/NormalModule.js:471:10)
    at /home/mark/GitProjects/ipfs-blog/node_modules/webpack/lib/NormalModule.js:503:5
    at /home/mark/GitProjects/ipfs-blog/node_modules/webpack/lib/NormalModule.js:358:12
    at /home/mark/GitProjects/ipfs-blog/node_modules/loader-runner/lib/LoaderRunner.js:373:3
    at iterateNormalLoaders (/home/mark/GitProjects/ipfs-blog/node_modules/loader-runner/lib/LoaderRunner.js:214:10)
    at Array.<anonymous> (/home/mark/GitProjects/ipfs-blog/node_modules/loader-runner/lib/LoaderRunner.js:205:4)
    at Storage.finished (/home/mark/GitProjects/ipfs-blog/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:55:16)
    at /home/mark/GitProjects/ipfs-blog/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:91:9
    at /home/mark/GitProjects/ipfs-blog/node_modules/graceful-fs/graceful-fs.js:123:16
    at FSReqCallback.readFileAfterClose [as oncomplete] (node:internal/fs/read/context:68:3) {
  opensslErrorStack: [ 'error:03000086:digital envelope routines::initialization error' ],
  library: 'digital envelope routines',
  reason: 'unsupported',
  code: 'ERR_OSSL_EVP_UNSUPPORTED'
}

Now here's the kicker. Installing this with npm imstall followed by an npm start gives me the above error. But installing it with yarn install and then folowed by npm start magically works!

Yeah, no clue what is happening here.

Side note though, the dependencies of this project are getting very old by now. It should be updated. Which is troublesome as just bluntly updating all of it isn't working anymore (i tried).

markg85 avatar Oct 07 '23 15:10 markg85