I am trying to host my React application on heroku but I keep getting the following errors:
JavaScript
x
39
39
1
-----> Installing dependencies
2
Installing node modules
3
npm ERR! code ERESOLVE
4
npm ERR! ERESOLVE could not resolve
5
npm ERR!
6
npm ERR! While resolving: react-credit-card-input@1.1.5
7
npm ERR! Found: react@17.0.2
8
npm ERR! node_modules/react
9
npm ERR! react@"^17.0.2" from the root project
10
npm ERR! peer react@">=16.8.0" from @emotion/react@11.7.1
11
npm ERR! node_modules/@emotion/react
12
npm ERR! @emotion/react@"^11.7.1" from the root project
13
npm ERR! peer @emotion/react@"^11.0.0-rc.0" from @emotion/styled@11.6.0
14
npm ERR! node_modules/@emotion/styled
15
npm ERR! @emotion/styled@"^11.6.0" from the root project
16
npm ERR! 3 more (@mui/material, @mui/styled-engine, @mui/system)
17
npm ERR! 3 more (@mui/material, @mui/styled-engine, @mui/system)
18
npm ERR! 31 more (@emotion/styled, @mui/base, @mui/icons-material, )
19
npm ERR!
20
npm ERR! Could not resolve dependency:
21
npm ERR! peer react@"^0.14.9 || ^15.3.0 || ^16.0.0-rc || ^16.0" from react-credit-card-input@1.1.5
22
npm ERR! node_modules/react-credit-card-input
23
npm ERR! react-credit-card-input@"^1.1.5" from the root project
24
npm ERR!
25
npm ERR! Conflicting peer dependency: react@16.14.0
26
npm ERR! node_modules/react
27
npm ERR! peer react@"^0.14.9 || ^15.3.0 || ^16.0.0-rc || ^16.0" from react-credit-card-input@1.1.5
28
npm ERR! node_modules/react-credit-card-input
29
npm ERR! react-credit-card-input@"^1.1.5" from the root project
30
npm ERR!
31
npm ERR! Fix the upstream dependency conflict, or retry
32
npm ERR! this command with --force, or --legacy-peer-deps
33
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
34
npm ERR!
35
npm ERR! See /tmp/npmcache.GoZcZ/eresolve-report.txt for a full report.
36
37
npm ERR! A complete log of this run can be found in:
38
npm ERR! /tmp/npmcache.GoZcZ/_logs/2022-06-27T11_25_24_489Z-debug-0.log
39
I have tried to do both --legacy-peer-deps
and npm install --force
but my build keeps getting failed. Is there a way to fix this recurrent problem.
Advertisement
Answer
I had to update the peer dependency for credit-card-input library in the package-lock.json
file to be compatible with my version of react and this solves my problem. I’m not sure if this is the best way but it solves the issue for me.