When trying to push my app to Heroku I am getting the following errors (edited for brevity):
remote: -----> Creating runtime environment
remote:
remote: NPM_CONFIG_LOGLEVEL=error
remote: NODE_VERBOSE=false
remote: NODE_ENV=production
remote: NODE_MODULES_CACHE=true
remote:
remote: -----> Installing binaries
remote: engines.node (package.json): >=v12.22.5
remote: engines.npm (package.json): >=6.14.14
remote:
remote: Resolving node version >=v12.22.5...
remote: Could not parse Version Requirements '>=v12.22.5': the given version requirement is invalid
remote: Downloading and installing node 17.0.1...
remote: Bootstrapping npm >=6.14.14 (replacing 8.1.0)...
remote: npm >=6.14.14 installed
My package.json (name redacted):
{
"name": "########",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start -p $PORT"
},
"engines": {
"node": "16.13.0"
},
"dependencies": {
"@stripe/react-stripe-js": "^1.4.1",
"@stripe/stripe-js": "^1.15.0",
"@zeit/next-css": "^1.0.0",
"axios": "^0.21.4",
"base-64": "^1.0.0",
"bootstrap": "^4.6.0",
"cookie": "^0.4.1",
"date-and-time": "^1.0.0",
"js-cookie": "^2.2.1",
"next": "^11.1.2",
"react": "17.0.2",
"react-bootstrap": "^1.5.2",
"react-calendar": "^3.3.1",
"react-datepicker": "^4.2.1",
"react-dom": "17.0.2",
"react-hook-form": "^7.17.4",
"react-icons": "^4.2.0",
"react-image-gallery": "^1.0.9",
"stripe": "^8.154.0"
}
}
... and further down the error trail:
remote: Error: error:0308010C:digital envelope routines::unsupported
remote: at new Hash (node:internal/crypto/hash:67:19)
remote: at Object.createHash (node:crypto:130:10)
remote: at BulkUpdateDecorator.hashFactory (/tmp/build_f62151d1/node_modules/next/dist/compiled/webpack/bundle5.js:138971:18)
remote: at BulkUpdateDecorator.update (/tmp/build_f62151d1/node_modules/next/dist/compiled/webpack/bundle5.js:138872:50)
remote: at /tmp/build_f62151d1/node_modules/next/dist/compiled/webpack/bundle5.js:59321:9
remote: at processTicksAndRejections (node:internal/process/task_queues:83:21)
remote: at runNextTicks (node:internal/process/task_queues:65:3)
remote: at processImmediate (node:internal/timers:437:9) {
remote: opensslErrorStack: [ 'error:03000086:digital envelope routines::initialization error' ],
remote: library: 'digital envelope routines',
remote: reason: 'unsupported',
remote: code: 'ERR_OSSL_EVP_UNSUPPORTED'
remote: }
remote: Node.js v17.0.1
remote:
remote: -----> Build failed
remote:
remote: We're sorry this build is failing! You can troubleshoot common issues here:
remote: https://devcenter.heroku.com/articles/troubleshooting-node-deploys
remote:
remote: Some possible problems:
remote:
remote: - Dangerous semver range (>) in engines.node
And, at the end of the error messages, I'm not sure if this is a separate error. I changed my master branch to main a while back and I'm not sure if this is also telling me that I may have done this incorrectly (seems fine on GitHub):
remote: Verifying deploy...
remote:
remote: ! Push rejected to #########.
remote:
To https://git.heroku.com/########.git
! [remote rejected] main -> main (pre-receive hook declined)
I have been 'around the houses' on Google trying various and many fixes with no answer that worked. It looks to me as if Heroku is reading the wrong information from my package.json? Many thanks for any replies.