Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to resolve dependency for installing html-parser

I am trying to install npm install react-html-parser in my current project. So I am trying to install the npm install react-html-parser but after I use the command.

npm ERR! code ERESOLVE
    npm ERR! ERESOLVE unable to resolve dependency tree
    PS D:\Ecommerce\user\ecom> npm install react-html-parser
    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@"^0.14.0 || ^15.0.0 || ^16.0.0-0" from [email protected]
    npm ERR! node_modules/react-html-parser
    npm ERR!   react-html-parser@"*" 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\hp\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\hp\AppData\Local\npm-cache\_logs\2022-02-19T13_09_05_987Z-debug-0.log

Here is my package json file

{
  "name": "ecom",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@testing-library/jest-dom": "^5.16.1",
    "@testing-library/react": "^12.1.2",
    "@testing-library/user-event": "^13.5.0",
    "axios": "^0.26.0",
    "bootstrap": "^5.1.3",
    "is-buffer": "^2.0.5",
    "react": "^17.0.2",
    "react-bootstrap": "^2.1.1",
    "react-dom": "^17.0.2",
    "react-router": "^5.2.0",
    "react-router-dom": "^5.2.0",
    "react-router-transition": "^2.1.0",
    "react-scripts": "5.0.0",
    "react-slick": "^0.28.1",
    "react-toastify": "^8.2.0",
    "slick-carousel": "^1.8.1",
    "web-vitals": "^2.1.3"
  },
  "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 don't understand what I can do. Please help me find the solution. Any sort of help would be appreciated. Thank you in advance.

like image 236
Ghulam Haider Avatar asked Mar 29 '26 19:03

Ghulam Haider


1 Answers

Here is a solution I found in the following answer

The idea is to replace react-html-parser with html-react-parser.

import parse from "html-react-parser";

...

{parse("<HTML string>")}

...
like image 189
Shahan M Avatar answered Apr 03 '26 17:04

Shahan M



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!