React-router: Attempted import error : 'createLocation' is not exported from 'history'

Created on 8 Aug 2020  路  2Comments  路  Source: ReactTraining/react-router

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"
    ]
  }

Most helpful comment

You're using the wrong version of history. Use a 4.x version.

All 2 comments

You're using the wrong version of history. Use a 4.x version.

You're using the wrong version of history. Use a 4.x version.

I now understand what you mean, after I read the documentation for npm "history". and now i have successfully used it with

"history": "^ 4.10.1",

Was this page helpful?
0 / 5 - 0 ratings

Related issues

davetgreen picture davetgreen  路  3Comments

alexyaseen picture alexyaseen  路  3Comments

ArthurRougier picture ArthurRougier  路  3Comments

tomatau picture tomatau  路  3Comments

ackvf picture ackvf  路  3Comments