Attempted import error : 'createLocation' is not exported from 'history'

Viewed 4091

I have just been refractoring my code and now I get this error

./node_modules/react-router-dom/esm/react-router-dom.js
Attempted import error : 'createLocation' is not exported from 'history'.

How do I fix this error, I have tried to search for the solution on Google but I cannot find any information on on this error, I have have also tried updating both react-router-dom and history but it didn't help, I have also tried uninstall and reinstall react-router-dom and history and deleting node_modules and use npm install nothing helped and I'm not using createLocation anywhere

My package.json:

 "name": "newdating",
  "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",
    "history": "^5.0.0",
    "react": "^16.13.1",
    "react-dom": "^16.13.1",
    "react-router": "^5.2.0",
    "react-router-dom": "^5.2.0",
    "react-scripts": "3.4.1",
    "react-select": "^3.1.0",
    "styled-components": "^5.1.1"
  },
  "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"
    ]
  }
1 Answers

You apparently have conflicting versions of history and react-router. According to the history README:

"(history) Version 5 is used in React Router version 6.

Documentation for version 4 can be found on the v4 branch. Version 4 is used in React Router versions 4 and 5."

Related