Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix] Resolve npm ERESOLVE error in dependencies. React version 18.2.0 #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

cristian-encalada
Copy link

Before the fix (current behavior)

npm ERR! trying to install react-svg-buttons

cristian@localhost:~/repos/quick-test$ npm install react-svg-buttons
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@"^18.2.0" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer react@"^15.4.1" from [email protected]
npm ERR! node_modules/react-svg-buttons
npm ERR!   react-svg-buttons@"*" 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! 
npm ERR! For a full report see:
npm ERR! /home/cristian/.npm/_logs/2024-01-20T16_56_02_533Z-eresolve-report.txt

npm ERR! A complete log of this run can be found in: /home/cristian/.npm/_logs/2024-01-20T16_56_02_533Z-debug-0.log

Changes made

  • Updated all dependencies on package.json to their latest versions. ("react": "^18.2.0")
npx npm-check-updates -u
npm install
  "dependencies": {
    "prop-types": "^15.8.1",
    "react-motion": "^0.5.2"
  },
  "devDependencies": {
    "babel-cli": "6.26.0",
    "babel-core": "6.26.3",
    "babel-preset-es2015": "6.9.0",
    "babel-preset-react": "6.24.1",
    "babel-preset-stage-2": "6.24.1",
    "prettier": "^3.2.4",
    "react": "^18.2.0"
  },
  • Updated peerDependencies to "react": "^18.2.0".
  "peerDependencies": {
    "react": "^18.2.0"
  },

Build and test

Build

npm run build
npm pack

Test after the fix

cristian@localhost:~/repos/quick-test$ npm install ../react-svg-buttons-improved/react-svg-buttons-0.5.0.tgz 
npm WARN ERESOLVE overriding peer dependency
npm WARN While resolving: [email protected]
npm WARN Found: [email protected]
npm WARN node_modules/react
npm WARN   peer react@"^18.2.0" from [email protected]
npm WARN   node_modules/react-dom
npm WARN     react-dom@"^18.2.0" from the root project
npm WARN   2 more (the root project, react-svg-buttons)
npm WARN 
npm WARN Could not resolve dependency:
npm WARN peer react@"^0.14.9 || ^15.3.0 || ^16.0.0" from [email protected]
npm WARN node_modules/react-motion
npm WARN   react-motion@"^0.5.2" from [email protected]
npm WARN   node_modules/react-svg-buttons
npm WARN 
npm WARN Conflicting peer dependency: [email protected]
npm WARN node_modules/react
npm WARN   peer react@"^0.14.9 || ^15.3.0 || ^16.0.0" from [email protected]
npm WARN   node_modules/react-motion
npm WARN     react-motion@"^0.5.2" from [email protected]
npm WARN     node_modules/react-svg-buttons

up to date, audited 277 packages in 1s

97 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities

Test with a basic Vite/React app

Test buttons Vite/React

This commit resolves the npm ERESOLVE error by updating the dependency
constraints in the package.json file. The conflict arises from the
react-svg-buttons package expecting React version "^15.4.1", which conflicts
with the React version "^18.2.0" used in the root project.

Changes made:
- Updated the React version in the react-svg-buttons package to be compatible
  with the root project's React version.
- Updated all dependencies on package.json to their latest versions.
	- npx npm-check-updates -u
	- npm install
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant