我正在开发一个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提前谢谢。
发布于 2017-08-22 20:02:30
在安装@types/history时,您只是向typescript编译器提供了有关history包的类型信息。而不是包本身。例如,请参阅此thread以了解一些详细信息。
因此,您必须安装history包才能使用它:
$ npm install --save history在他们的github rep上查看更多关于它的用法的信息。
发布于 2020-10-02 20:02:48
尝试使用npm安装历史记录和反应路由器dom包
npm install --save history
npm install react-router-dom --save https://stackoverflow.com/questions/45817017
复制相似问题