NAMAN KOTHARI
NAMAN KOTHARI

Reputation: 41

how do i fix the upstream dependency error? i have tried doing npm install --legacy-peer-deps and npm install --force but that causes problems further

This is the error I am getting(can someone please also explain to me why such errors are occurring and if there is a way to update the npm to the version of react I have.):

PS C:\Naman Kothari\udemy course\react\thelastone> npm i react-tilt
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: [email protected]
npm ERR! Found: [email protected]
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.0.0 || ^16.0.0-beta || ^16.0.0" from [email protected]
npm ERR! node_modules/react-tilt
npm ERR!   react-tilt@"*" 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\namrata kothari\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\namrata kothari\AppData\Local\npm-cache\_logs\2021-04-24T15_15_44_230Z-debug.log

This is my package.json (it mainly consists of all the packages that were default created when I installed the create-react-app npm).

{
  "name": "thelastone",
  "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",
    "react": "^17.0.2",
    "react-dom": "^17.0.2",
    "react-scripts": "4.0.3",
    "tachyons": "^4.12.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"
    ]
  }
}

Upvotes: 4

Views: 2613

Answers (2)

vimuth
vimuth

Reputation: 5612

I faced the same issue and had to do folow these steps to resolve.

  1. Go to your project in Netlify and click on your site name.
  2. Click on the Site settings button or tab on the right most side of the menu.
  3. Click on Environment variables (New) on the left pane menu.
  4. Click on the Add Variable button.
  5. Type CI into the key input field, and then type false into the values field, and then click on the Create variable button.
  6. Repeat the steps from step 4 to add another Environment variable by setting the key input to NPM_FLAGS and set values input to --legacy-peer-deps.
  7. Once you are done click on the Deploys tab menu at the top of the page and then click on the Trigger deploy button and select Clear cache and deploy site option.

I got it from this link

Apart from this I had to addnetlify.toml file to root directory and add this lines too.

[build]
  command = "npm install --legacy-peer-deps --force && npm run build"

Upvotes: 0

danieladla
danieladla

Reputation: 11

The problem I had was that react-tilt didn`t work with version 17 of react.

I tried with the package 'react-tilty' which solved my problem:

npm i react-tilty

Upvotes: 1

Related Questions