Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Module not found Error: Can't resolve 'history' in @types/history

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.

like image 214
BEJGAM SHIVA PRASAD Avatar asked Aug 22 '17 11:08

BEJGAM SHIVA PRASAD


2 Answers

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.

like image 171
Amid Avatar answered Sep 20 '22 00:09

Amid


try to install history and react router dom package using npm

npm install --save history
npm install react-router-dom --save 
like image 30
Codemaker Avatar answered Sep 18 '22 00:09

Codemaker