webstorm里面,react-router-dom冲突

最后更新于2022年9月2日 10:18:39

react-route-dom是前端路由的库,在webstorm里面,会用typings来管理一些常用的库的缓存,并且在自动补全的时候优先从这里面找。与此同时,你自己还会在npm里头再下一个最新版的,这就出问题了:
IDE从typings里面找到的版本是5.3.3,但是最新的是6.3.0,最明显的就是没有Routers这个常用的TAG,只有Switch。还就那个恶心。

解决方法:
Webstorm resolve wrong path when using react-router-dom@next

The IDE downloads typings for some popular libraries to its configuration folder and uses it to enhance code completion. You can remove the auto-downloaded typings from your /javascript/typings (https://www.jetbrains.com/help/webstorm/directories-used-by-the-ide-to-store-settings-caches-plugins-and-logs.html#system-directory) and then either disable typescript.external.type.definitions Registry key or remove react-router-dom from typescript.external.type.definitions.packages
The Registry can be located via: Help > Find action > type Registry…

第一步:从这段得知,在Help > Find action > type Registry...标签下可以打开Webstorm的注册表,然后:

Cannot resolve symbol ‘Routes’

In the registry, look for typescript.external.type.defintions.packages key and in the value of that field, only remove the react-router-dom field from the values.
Also Go to File -> Invalidate Caches -> select “Clear file system cache and Local History” -> click “Invalidate and Restart”

第二步:在注册表里头的 typescript.external.type.defintions.packages这个字段下删除react-router-dom部分
第三步:依次选择File -> Invalidate Caches -> select "Clear file system cache and Local History" -> click "Invalidate and Restart"

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值