You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

引入react-router-dom出现15个错误:AbortedDeferredError导出未找到

解决react-router-dom导入报错的方案

核心原因

react-router-dom与依赖的react-router版本不兼容,导致react-router-dom尝试从react-router导出不存在的AbortedDeferredError。

具体解决步骤

  • 卸载当前的react-router和react-router-dom
    npm uninstall react-router react-router-dom
    # 使用yarn的话执行:
    yarn remove react-router react-router-dom
    
  • 重新安装同版本的两个包,推荐安装稳定最新版
    npm install react-router react-router-dom
    # 使用yarn的话执行:
    yarn add react-router react-router-dom
    
  • 若需要指定特定版本(如v6.14.2),执行:
    npm install react-router@6.14.2 react-router-dom@6.14.2
    
  • 清除缓存并重新构建项目
    npm cache clean --force
    npm run build
    

额外检查

  • 查看package.json,确认react-router和react-router-dom的版本号完全一致
  • 若使用create-react-app,可删除node_modules和package-lock.json(或yarn.lock)后重新执行安装命令

内容的提问来源于stack exchange,提问作者Lester Ivan Dalaguit

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.16 05:20:29