首页 > 解决方案 > ReactJS can't import 'react-router-dom' anymore

问题描述

A few days ago I just worked fine on my website, and could use the following syntax: 'import { BrowserRouter as Router, Route, Link } from "react-router-dom";' in my program. But today, when I wanted to go on with programming my website I got the following errors in console: https://pastebin.com/FXqKAyzd


This is odd tho because it worked just fine a few days ago. So I thought, maybe there was an update, and I updated 'react-router' and 'react-router-dom' to the newest version (at the time being: '5.0.0'). I hope someone can tell me, how to fix this, and why it says import Router from "react-router/es/undefined" <- undefined? and what the support for the latter is?

标签: javascriptnode.jsreactjsreact-routerreact-router-dom

解决方案


所以我只是解决了这个问题。或者更好地说:我的笔记本电脑做到了。我在我的笔记本电脑上提取了最后的更改,执行了“npm install”,它在 package-lock.json 中添加了一行代码

"minimatch": {
  "version": "3.0.4",
  "bundled": true,
  "optional": true, //this one here
  "requires": {
  "brace-expansion": "^1.1.7"
}

然后我推了它,又把它拉到了电脑上,瞧,它又工作了。这让我有点困惑,但没关系。顺便说一句:由于@Vikas Singh,我尝试了很多谢谢!


推荐阅读