Source:  Twitter logo

Am developing a React Application where I want to use @types/history module..

Installed

npm install --save @types/history

And in my component file trying to import like

import { createBrowserHistory, History } from 'history' 

And

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

But throwing exception like

Module not found: Can't resolve 'history' in

Thanks in advance.

When installing @types/history you are just providing typescript compiler with type information about history package. Not the package itself. See for example this thread for some details.

Therefore - you must install history package in order to use it:

$ npm install --save history

See more info about its usage at their github rep.

23 users liked answer #0dislike answer #023
Amid profile pic
Amid

try to install history and react router dom package using npm

npm install --save history
npm install react-router-dom --save 
4 users liked answer #1dislike answer #14
Codemaker profile pic
Codemaker

Copyright © 2022 QueryThreads

All content on Query Threads is licensed under the Creative Commons Attribution-ShareAlike 3.0 license (CC BY-SA 3.0).