Hello FCCampers,
I keep getting this error when trying deploy my app on Heroku.
Stuff I tried:
-Checked that I’m using heroku/nodejs buildpack
-Tried deleting package-lock.json (both root and client) before
-Tried deleting any existing ‘build’ folders with
find . -name build -exec rm -rf {} \;
(that just screwed some of my node_modules, so I had to go back to a previous version of my project → done)
None of these things worked. I need your help!
At this point, I’m running: git push heroku main
Here is the terminal output:
Air-de-David:crown-clothing David$ git status
On branch main
Your branch is up to date with 'origin/main'.
nothing to commit, working tree clean
Air-de-David:crown-clothing David$ git push heroku main
Enumerating objects: 86, done.
Counting objects: 100% (86/86), done.
Delta compression using up to 4 threads
Compressing objects: 100% (25/25), done.
Writing objects: 100% (57/57), 23.63 KiB | 654.00 KiB/s, done.
Total 57 (delta 34), reused 50 (delta 31)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Building on the Heroku-20 stack
remote: -----> Using buildpack: heroku/nodejs
remote: -----> Node.js app detected
remote:
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): 15.5.1
remote: engines.npm (package.json): 7.3.0
remote:
remote: Resolving node version 15.5.1...
remote: Downloading and installing node 15.5.1...
remote: npm 7.3.0 already installed with node
remote:
remote: -----> Restoring cache
remote: - node_modules
remote:
remote: -----> Installing dependencies
remote: Installing node modules
remote:
remote: added 359 packages, and audited 360 packages in 16s
remote:
remote: 8 packages are looking for funding
remote: run `npm fund` for details
remote:
remote: found 0 vulnerabilities
remote:
remote: -----> Build
remote: Detected both "build" and "heroku-postbuild" scripts
remote: Running heroku-postbuild
remote:
remote: > crown-clothing-server@1.0.0 heroku-postbuild
remote: > cd client && npm install && npm install --only=dev --no-shrinkwrap && npm run build
remote:
remote:
remote: added 2187 packages, and audited 2188 packages in 4m
remote:
remote: 127 packages are looking for funding
remote: run `npm fund` for details
remote:
remote: found 0 vulnerabilities
remote: npm ERR! code ERESOLVE
remote: npm ERR! ERESOLVE unable to resolve dependency tree
remote: npm ERR!
remote: npm ERR! Found: @babel/core@7.12.3
remote: npm ERR! node_modules/@babel/core
remote: npm ERR! @babel/core@"7.12.3" from react-scripts@4.0.1
remote: npm ERR! node_modules/react-scripts
remote: npm ERR! react-scripts@"4.0.1" from the root project
remote: npm ERR! @babel/core@"^7.9.0" from @svgr/webpack@5.4.0
remote: npm ERR! node_modules/@svgr/webpack
remote: npm ERR! @svgr/webpack@"5.4.0" from react-scripts@4.0.1
remote: npm ERR! node_modules/react-scripts
remote: npm ERR! react-scripts@"4.0.1" from the root project
remote: npm ERR! 9 more (babel-jest, babel-loader, ...)
remote: npm ERR!
remote: npm ERR! Could not resolve dependency:
remote: npm ERR! peer @babel/core@"^7.13.0" from @babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining@7.13.12
remote: npm ERR! node_modules/@babel/preset-env/node_modules/@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining
remote: npm ERR! @babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining@"^7.13.12" from @babel/preset-env@7.13.12
remote: npm ERR! node_modules/@babel/preset-env
remote: npm ERR! @babel/preset-env@"^7.9.5" from @svgr/webpack@5.4.0
remote: npm ERR! node_modules/@svgr/webpack
remote: npm ERR! @svgr/webpack@"5.4.0" from react-scripts@4.0.1
remote: npm ERR! node_modules/react-scripts
remote: npm ERR!
remote: npm ERR! Fix the upstream dependency conflict, or retry
remote: npm ERR! this command with --force, or --legacy-peer-deps
remote: npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
remote: npm ERR!
remote: npm ERR! See /tmp/npmcache.uVzr8/eresolve-report.txt for a full report.
remote:
remote: npm ERR! A complete log of this run can be found in:
remote: npm ERR! /tmp/npmcache.uVzr8/_logs/2021-03-30T08_19_48_172Z-debug.log
remote: npm ERR! code 1
remote: npm ERR! path /tmp/build_200f93e9
remote: npm ERR! command failed
remote: npm ERR! command sh -c cd client && npm install && npm install --only=dev --no-shrinkwrap && npm run build
remote:
remote: npm ERR! A complete log of this run can be found in:
remote: npm ERR! /tmp/npmcache.uVzr8/_logs/2021-03-30T08_19_48_213Z-debug.log
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: If you're stuck, please submit a ticket so we can help:
remote: https://help.heroku.com/
remote:
remote: Love,
remote: Heroku
remote:
remote: ! Push rejected, failed to compile Node.js app.
remote:
remote: ! Push failed
remote: !
remote: ! ## Warning - The same version of this code has already been built: 84b11ca1928f74010fdaa34477ec773b9039e802
remote: !
remote: ! We have detected that you have triggered a build from source code with version 84b11ca1928f74010fdaa34477ec773b9039e802
remote: ! at least twice. One common cause of this behavior is attempting to deploy code from a different branch.
remote: !
remote: ! If you are developing on a branch and deploying via git you must run
remote: !
remote: ! git push heroku <branchname>:main
remote: !
remote: ! This article goes into details on the behavior:
remote: ! https://devcenter.heroku.com/articles/duplicate-build-version
remote:
remote: Verifying deploy...
remote:
remote: ! Push rejected to my-crown-shop.
remote:
To https://git.heroku.com/my-crown-shop.git
! [remote rejected] main -> main (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/my-crown-shop.git'
Here is also my file structure:
root package.json
{
"name": "crown-clothing-server",
"version": "1.0.0",
"engines": {
"node": "15.5.1",
"npm": "7.3.0"
},
"scripts": {
"client": "cd client && npm start",
"server": "nodemon server.js",
"build": "cd client && npm run build",
"dev": "concurrently --kill-others-on-fail \"npm run server\" \"npm run client\"",
"start": "node server.js",
"heroku-postbuild": "cd client && npm install && npm install --only=dev --no-shrinkwrap && npm run build"
},
"dependencies": {
"body-parser": "^1.18.3",
"compression": "1.7.4",
"dotenv": "7.0.0",
"express": "^4.16.4",
"stripe": "6.28.0"
},
"devDependencies": {
"concurrently": "^6.0.0",
"nodemon": "^1.19.1"
}
}
client package.json
{
"name": "crown-clothing",
"version": "0.1.0",
"private": true,
"proxy": "http://localhost:5000",
"dependencies": {
"@testing-library/jest-dom": "^5.11.9",
"@testing-library/react": "^11.2.4",
"@testing-library/user-event": "^12.6.3",
"axios": "^0.21.1",
"firebase": "^8.2.6",
"lodash.memoize": "^4.1.2",
"node-sass": "^4.14.1",
"react": "^17.0.1",
"react-dom": "^17.0.1",
"react-redux": "^7.2.2",
"react-router-dom": "^5.2.0",
"react-scripts": "4.0.1",
"react-stripe-checkout": "^2.6.3",
"redux": "^4.0.5",
"redux-logger": "^3.0.6",
"redux-persist": "^6.0.0",
"redux-saga": "^1.1.3",
"redux-thunk": "^2.3.0",
"reselect": "^4.0.0",
"styled-components": "^5.2.1",
"web-vitals": "^0.2.4"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
And also, the whole project in case you want to dig deeper: https://github.com/david-borja/crown-clothing.git
Any comments or feedback will be more than welcome!
Thanks in advance people