gpt4 book ai didi

reactjs - 找不到模块错误 : Can't resolve 'history' in @types/history

转载 作者:行者123 更新时间:2023-12-03 13:46:10 25 4
gpt4 key购买 nike

我正在开发一个我想使用的 React 应用程序 @types/history模块..

已安装

npm install --save @types/history

在我的组件文件中尝试导入
import { createBrowserHistory, History } from 'history' 


import { createBrowserHistory, History } from '@types/history'

但是抛出异常
Module not found: Can't resolve 'history' in

提前致谢。

最佳答案

安装 @types/history 时,您只是为 typescript 编译器提供了关于 history 的类型信息。包裹。不是包裹本身。例如,参见 thread了解一些细节。

因此 - 您必须安装 history包以使用它:

$ npm install --save history

在他们的 github rep 上查看有关其使用的更多信息.

关于reactjs - 找不到模块错误 : Can't resolve 'history' in @types/history,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45817017/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com