Heroku Push rejected, Node.js & React App - node.js

Node.Js + React App, all work fine on localhost, when i push to heroku, Push rejected, idk why.
Please help my heroes.
Heroku Push logs:
> NPM_CONFIG_PRODUCTION=false npm install --prefix frontend && npm run build --prefix frontend
npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR!
npm ERR! While resolving: react-paypal-button-v2#2.6.3
npm ERR! Found: react#18.2.0
npm ERR! node_modules/react
npm ERR! react#"^18.2.0" from the root project
npm ERR! peer react#">=16.3.2" from #restart/context#2.1.4
npm ERR! node_modules/#restart/context
npm ERR! #restart/context#"^2.1.4" from react-bootstrap#1.6.6
npm ERR! node_modules/react-bootstrap
npm ERR! react-bootstrap#"^1.6.6" from the root project
npm ERR! 16 more (#restart/hooks, #testing-library/react, ...)
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react#"^0.14.6 || 15.x.x || 16.x.x || 17.x.x" from react-paypal-button-v2#2.6.3
npm ERR! node_modules/react-paypal-button-v2
npm ERR! react-paypal-button-v2#"^2.6.3" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: react#17.0.2
npm ERR! node_modules/react
npm ERR! peer react#"^0.14.6 || 15.x.x || 16.x.x || 17.x.x" from react-paypal-button-v2#2.6.3
npm ERR! node_modules/react-paypal-button-v2
npm ERR! react-paypal-button-v2#"^2.6.3" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR! See /tmp/npmcache.1sG84/eresolve-report.txt for a full report.
npm ERR! A complete log of this run can be found in:
npm ERR! /tmp/npmcache.1sG84/_logs/2022-12-15T17_08_01_767Z-debug-0.log
-----> Build failed
package.json React:
{
"name": "frontend",
"proxy": "http://127.0.0.1:5000",
"version": "0.1.0",
"private": true,
"dependencies": {
"#testing-library/jest-dom": "^4.2.4",
"#testing-library/react": "^9.5.0",
"#testing-library/user-event": "^7.2.1",
"axios": "^1.2.1",
"install": "^0.13.0",
"react": "^18.2.0",
"react-bootstrap": "^1.6.6",
"react-dom": "^18.2.0",
"react-helmet": "^6.1.0",
"react-paypal-button-v2": "^2.6.3",
"react-redux": "^8.0.5",
"react-router-bootstrap": "^0.25.0",
"react-router-dom": "^5.3.4",
"react-scripts": "^5.0.1",
"redux": "^4.2.0",
"redux-devtools-extension": "^2.13.9",
"redux-thunk": "^2.4.2"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"install-peers": "^1.0.4"
}
}
package.json Node.js:
{
"name": "backend",
"version": "1.0.0",
"description": "",
"main": "server.js",
"type": "module",
"engines": {
"node": "17.x"
},
"scripts": {
"start": "node backend/server",
"server": "nodemon backend/server",
"client": "npm start --prefix frontend",
"dev": "concurrently \"npm run server\" \"npm run client\"",
"data:import": "node backend/seeder",
"data:destroy": "node backend/seeder -d",
"heroku-postbuild": "NPM_CONFIG_PRODUCTION=false npm install --prefix frontend && npm run build --prefix frontend"
},
"author": "",
"license": "MIT",
"dependencies": {
"bcryptjs": "^2.4.3",
"colors": "^1.4.0",
"dotenv": "^8.6.0",
"express": "^4.18.2",
"express-async-handler": "^1.2.0",
"jsonwebtoken": "^8.5.1",
"mongoose": "^5.13.15",
"morgan": "^1.10.0",
"multer": "^1.4.4"
},
"devDependencies": {
"concurrently": "^5.3.0",
"nodemon": "^2.0.20"
}
}
Node.Js + React App, all work fine on localhost, when i push to heroku, Push rejected, idk why.
Please help my heroes.
Thanks for help.

You are directly depending on React 18 but react-paypal-button-v2#2.6.3 (the latest release at the time of writing) is not compatible with that version yet, as described in the error message:
npm ERR! Could not resolve dependency:
npm ERR! peer react#"^0.14.6 || 15.x.x || 16.x.x || 17.x.x" from react-paypal-button-v2#2.6.3
npm ERR! node_modules/react-paypal-button-v2
If you don't need anything in particular from React 18, your best bet is to downgrade to version 17.
If you need React 18, the safest thing to do is to wait for a new version of react-paypal-button that declares a compatible peer dependency. There is an open issue on the project requesting this.
The last option, which I do not recommend, is to ask Heroku to use legacy peer deps behaviour. This behaviour is deprected for a reason, and while it may let your install proceed, it could also lead to unpredictable bugs.

I see you running npm install --prefix frontend at the start of your Heroku logs. It should work if you add the flag --legacy-peer-deps to that command. Just a suggestion, use npm ci instead of the npm install to use the exact same dependencies locally and in the production server (you will have to push the package-lock.json as well, see the command reference: https://docs.npmjs.com/cli/v9/commands/npm-ci).

Related

Upgrading to react 18 results in package dependencies errors

I have the following package.json file:
{
"name": "web",
"version": "0.1.0",
"private": true,
"dependencies": {
"#emotion/react": "^11.10.0",
"#emotion/styled": "^11.10.0",
"#fontsource/roboto": "^4.5.7",
"#mui/icons-material": "^5.8.4",
"#mui/lab": "^5.0.0-alpha.93",
"#mui/material": "^5.9.3",
"#reduxjs/toolkit": "^1.8.3",
"#testing-library/jest-dom": "^5.16.4",
"#testing-library/react": "^13.3.0",
"#testing-library/user-event": "^13.5.0",
"animate.css": "^4.1.1",
"generate-password-browser": "^1.1.0",
"notistack": "^2.0.5",
"query-string": "^7.1.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-redux": "^8.0.2",
"react-router-dom": "^6.3.0",
"react-scripts": "5.0.1",
"string-to-color": "^2.2.2",
"stylis-plugin-rtl": "^2.1.1",
"traverse": "^0.6.6",
"typed.js": "^2.0.12",
"web-vitals": "^2.1.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"
]
}
}
I have created this project using create-react-app just now, so everything is clean and new, I have only installed additional packages.
Now, I want to install the following package:
react-swipeable-views
Which had over 260,000 downloads this week,
$ npm i react-swipeable-views
and I'm getting this error:
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: web#0.1.0
npm ERR! Found: react#18.2.0
npm ERR! node_modules/react
npm ERR! react#"^18.2.0" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react#"^15.3.0 || ^16.0.0 || ^17.0.0" from react-swipeable-views#0.14.0
npm ERR! node_modules/react-swipeable-views
npm ERR! react-swipeable-views#"*" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR! See /home/sam/.npm/eresolve-report.txt for a full report.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/sam/.npm/_logs/2022-08-04T16_50_51_600Z-debug-0.log
Everything was working just fine before the idea of moving to react 18.
Thanks react, now how do I fix this problem? I have tens of other dependencies which I'm unable to install because of this error, I was able to rescue the ones listed above in the package.json file, thank god.
If I wanted to roll back to react#17 I can't because there's no way you can do it since create-react-app does not have such an option, and if you npm un react and npm i react#17 the errors will remain because create-react-app installs other dependencies and not only react.
Any help to get out of this problem?
with explanation, why this is happening if possible 🌹.
npm ERR! peer react#"^15.3.0 || ^16.0.0 || ^17.0.0" from react-swipeable-views#0.14.0
That library doesn't support anything in 18 yet. According to the project github the issue was opened already this year.

Error Could not resolve dependency: redux-react-session

I need to install this package https://www.npmjs.com/package/redux-react-session
installing it with npm npm i redux-react-session shows this error:
PS C:\Users\michael\Desktop\login and signup\client> npm i redux-react-session
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: client#0.1.0
npm ERR! Found: react#18.1.0
npm ERR! node_modules/react
npm ERR! react#"^18.1.0" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react#"^0.14.0 || ^15.0.0 || ^16.0.0" from redux-react-session#2.6.1
npm ERR! node_modules/redux-react-session
npm ERR! redux-react-session#"*" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
package.json:
{
"name": "client",
"version": "0.1.0",
"private": true,
"dependencies": {
"#emotion/react": "^11.9.0",
"#emotion/styled": "^11.8.1",
"#mui/material": "^5.8.0",
"#mui/styled-engine-sc": "^5.8.0",
"#testing-library/jest-dom": "^5.16.4",
"#testing-library/react": "^13.2.0",
"#testing-library/user-event": "^13.5.0",
"antd": "^4.20.5",
"axios": "^0.27.2",
"formik": "^2.2.9",
"react": "^18.1.0",
"react-dom": "^18.1.0",
"react-icons": "^4.4.0",
"react-loader-spinner": "^5.1.5",
"react-redux": "^8.0.2",
"react-router-dom": "^6.3.0",
"react-scripts": "5.0.1",
"redux": "^4.2.0",
"redux-thunk": "^2.4.1",
"styled-components": "^5.3.5",
"web-vitals": "^2.1.4",
"yup": "^0.32.11"
},
"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"
]
}
}
when installing npm packages?
There are two solutions to resolve this issue. Let us look at each of those in detail.
Solution 1: Ignore the peerDependencies
The easiest way to fix the issue is to pass an additional parameter –legacy-peer-deps to npm install. The --legacy-peer-deps tells the npm to ignore the peer dependencies and continue the installation of the package.
Try the below command to install the dependencies for your project.
npm install --save --legacy-peer-deps
You can also set this permanently by adding this into a configuration by running the below command.
npm config set legacy-peer-deps true
Note: In this solution, the peer dependencies will not be installed by default, even if you are using the latest version of NPM.
Solution 2: Using –force
The other solution is to use the --force flag. The -f or --force argument will force npm to fetch remote resources even if a local copy exists on disk.
Step 1: Delete the current node_modules. You can remove it by using the below command.
rm -rf node_modules
Step 2: Remove the package-lock.json by running the below command
rm package-lock.json
Step 3: Clear the npm cache and perform the clean installation with --force flag as shown below.
npm cache clean --force
npm install --force
By performing the above steps, you should resolve the issue successfully.

I can't solve the dependency tree every time i try to install #craco/craco

Unable to solve dependency tree trying to install tailwind.
This is my package.json:
{
"name": "front-end",
"version": "0.1.0",
"private": true,
"devDependencies": {
"autoprefixer": "^9.8.8",
"eslint": "^8.15.0",
"jest": "^28.1.0",
"postcss": "^7.0.39",
"tailwindcss": "npm:#tailwindcss/postcss7-compat#^2.2.17"
},
"dependencies": {
"#craco/craco": "^6.4.3",
"#testing-library/jest-dom": "^5.16.1",
"#testing-library/react": "^12.1.2",
"#testing-library/user-event": "^13.5.0",
"axios": "^0.25.0",
"js-cookie": "^3.0.1",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-redux": "^7.2.6",
"react-router-dom": "^6.2.1",
"react-scripts": "5.0.0",
"redux": "^4.1.2",
"redux-devtools-extension": "^2.13.9",
"redux-saga": "^1.1.3",
"router": "^1.3.6",
"web-vitals": "^2.1.3"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"eject": "react-scripts eject",
"test": "jest",
"lint": "eslint .",
"lint:fix": "eslint --fix --ext .js,.jsx ."
},
"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"
]
}
}
This is what I see in my console:
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: front-end#0.1.0
npm ERR! Found: react-scripts#5.0.0
npm ERR! node_modules/react-scripts
npm ERR! react-scripts#"5.0.0" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react-scripts#"^4.0.0" from #craco/craco#6.4.3
npm ERR! node_modules/#craco/craco
npm ERR! #craco/craco#"^6.4.3" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR! See C:\Users\Tejas\AppData\Local\npm-cache\eresolve-report.txt for a full report.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Tejas\AppData\Local\npm-cache\_logs\2022-05-14T14_36_01_226Z-debug-0.log
i am trying to configure tailwind css and to override reactcss i am trying install #craco/craco but i am getting this error i tried useing
npm install --save --legacy-peer-deps
and installed craco using this
npm install #craco/craco --save --legacy-peer-deps
but after that it is giving me error
Downgrade the version of react-script from 5.0.0 to 4.0.0

Cannot run NPM install because it's 'unable to resolve dependency tree'

I had some issues with my node_modules so I went to delete the node_modules and run npm install. Boy was that a mistake. My project is completely messed up. When I run npm install npm it sends back this:
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: project#0.1.0
npm ERR! Found: react#17.0.2
npm ERR! node_modules/react
npm ERR! react#"^17.0.2" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react#"15.3.0 - 16.x" from react-vis#1.11.7
npm ERR! node_modules/react-vis
npm ERR! react-vis#"^1.11.7" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR! See /Users/Cole/.npm/eresolve-report.txt for a full report.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/Cole/.npm/_logs/2021-05-26T10_34_07_786Z-debug.log
Someone please help me!
Edit: Here is my package.json.
{
"name": "project",
"version": "0.1.0",
"private": true,
"dependencies": {
"#testing-library/jest-dom": "^5.12.0",
"#testing-library/react": "^11.2.6",
"#testing-library/user-event": "^12.8.3",
"axios": "^0.21.1",
"npm": "^7.14.0",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-redux": "^7.2.4",
"react-router-dom": "^5.2.0",
"react-scripts": "^4.0.3",
"react-vis": "^1.11.7",
"redux": "^4.1.0",
"web-vitals": "^1.1.1"
},
"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"
]
}
}
Not quite sure what I did that was so detrimental but this has been a painful experience.
When running npm audit it shows that there are 87 vulnerabilities.
Running npm audit fix and npm audit fix --force do not fix anything.
Is there a way to refresh all the node_modules? Go back to square one and re-install all dependencies again?
Seems like react-vis has a peer dependency of react#"15.3.0 - 16.x". Since you have react#17.0.2, it complains. Try changing
"react": "^17.0.2",
"react-dom": "^17.0.2",
to
"react": "^16.14.0",
"react-dom": "^16.14.0",

Conflicts in React dependency tree

When running the react app I got this error in console - SharedArrayBuffer will require cross-origin isolation as of M91, around May 2021. See https://developer.chrome.com/blog/enabling-shared-array-buffer/ for more details.
Based on StackOverflow's suggestions I tried updating react version. I had version 16 and switched to 17. But now there are conflicts in the dependency tree. When I try to npm install this is the error I'm getting:
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! Found: react#17.0.2
npm ERR! node_modules/react
npm ERR! react#"^17.0.2" from the root project
npm ERR! peer react#">=16.8.0" from #emotion/react#11.1.5
npm ERR! node_modules/#emotion/react
npm ERR! #emotion/react#"^11.1.1" from react-select#4.3.0
npm ERR! node_modules/react-select
npm ERR! react-select#"^4.2.1" from the root project
npm ERR! 17 more (#material-ui/core, #material-ui/lab, ...)
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react#"^0.14 || ^15.0.0 || ^16.0.0-alpha" from airbnb-prop-types#2.160
npm ERR! node_modules/airbnb-prop-types
npm ERR! airbnb-prop-types#"^2.16.0" from enzyme-adapter-utils#1.14.0
npm ERR! node_modules/enzyme-adapter-utils
npm ERR! enzyme-adapter-utils#"^1.14.0" from enzyme-adapter-react-16#1.15.6
npm ERR! node_modules/enzyme-adapter-react-16
npm ERR! dev enzyme-adapter-react-16#"^1.15.6" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR! See C:\Users\USER\AppData\Local\npm-cache\eresolve-report.txt for a full rport.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\USER\AppData\Local\npm-cache\_logs\2021-04-25T15_17_39_361Z-dbug.log
package.json :
{
"name": "frontend",
"version": "0.1.0",
"private": true,
"dependencies": {
"#material-ui/core": "^4.11.3",
"#material-ui/lab": "^4.0.0-alpha.57",
"#testing-library/jest-dom": "^5.11.9",
"#testing-library/react": "^11.2.5",
"#testing-library/user-event": "^12.8.3",
"aos": "^2.3.4",
"react": "^17.0.2",
"react-dom": "^17.0.1",
"react-icons": "^4.2.0",
"react-router-dom": "^5.2.0",
"react-scripts": "4.0.3",
"react-select": "^4.2.1",
"react-spring": "^8.0.27",
"styled-components": "^5.2.1",
"web-vitals": "^1.1.0"
},
"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"
]
},
"devDependencies": {
"enzyme": "^3.11.0",
"enzyme-adapter-react-16": "^1.15.6",
"jest": "^26.6.0",
"react-dev-utils": "^11.0.4"
},
"proxy": "http://localhost:8080"
}
As I understand the error occurs because of the version of the enzyme. I tried upgrading it to version 17, but react doesn't let me do it and I get the above-given error.
What could be the solution to resolve the dependency conflicts?
I had the same issue, so I've installed the dependencies with yarn. and it worked like magic.
If you have React version 17, you can use this unofficial adapter for React 17 for enzyme.
import { configure } from 'enzyme';
import Adapter from '#wojtekmaj/enzyme-adapter-react-17';
configure({ adapter: new Adapter() });
Your package.json file contains the declaration of which version of React you're using. As long as your project is has all it needs from the version of React that enzyme-adapter-react-16 requires - which is ^16.4.0-0 according to Justin Mitchell - you can use that.
"dependencies": {
...
"react": "^16.4.0-0",
"react-dom": "^16.4.0-0",
...
}

Resources