尝试导入错误:未从“历史记录”中导出“ createLocation”

时间:2020-08-07 14:28:47

标签: node.js reactjs

我刚刚修改了我的代码,现在我得到了这个错误

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

如何解决此错误,我尝试在Google上搜索解决方案,但找不到有关此错误的任何信息,我也尝试过更新react-router-dom和历史记录,但没有帮助,我也尝试过卸载并重新安装react-router-dom和历史记录,并删除node_modules并使用npm install没有任何帮助,而且我在任何地方都不使用createLocation

我的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 个答案:

答案 0 :(得分:3)

您显然有historyreact-router的冲突版本。根据{{​​1}}自述文件:

”(历史记录)版本5在React Router版本6中使用。

版本4的文档可以在v4分支上找到。版本4用于React Router版本4和5。“