I am building a Gatsby site. I upgraded Node js to v17.0.1, when run the build, there is an error:
Error: digital envelope routines::unsupported
opensslErrorStack: [ 'error:03000086:digital envelope routines::initialization error' ],
library: 'digital envelope routines',
reason: 'unsupported',
code: 'ERR_OSSL_EVP_UNSUPPORTED'
If downgrade it to v16, it works fine, build will be successful. Any idea? From Googling, this may be a similar issue: https://github.com/handshake-org/hs-airdrop/issues/48
CodePudding user response:
You should always use LTS which is version 14 at this moment and in 5 days from now it will be version 16 https://nodejs.org/en/about/releases/
CodePudding user response:
Gatsby must be using an algorithm or key size which is no longer allowed by default with OpenSSL 3.0.
UPDATED
After some digging it most likely is a webpack issue - https://github.com/webpack/webpack/issues/14532
From Node 17's announcement post:
If you hit an
ERR_OSSL_EVP_UNSUPPORTED
error in your application with Node.js 17, it’s likely that your application or a module you’re using is attempting to use an algorithm or key size which is no longer allowed by default with OpenSSL 3.0. A new command-line option,--openssl-legacy-provider
, has been added to revert to the legacy provider as a temporary workaround for these tightened restrictions.
Running this on the terminal might look like:
node --openssl-legacy-provider ./node_modules/.bin/gatsby build
You can also pass this in via the NODE_OPTIONS environment variable.
So if you'd like to continue using the NPM script, you can change the build
script to:
// package.json
{
"scripts": {
"build": "export NODE_OPTIONS=--openssl-legacy-provider; gatsby build"
}
}