Oliver Watkins
Oliver Watkins

Reputation: 13509

installing 'react-router' gives inconsistent version

I installed the react router by doing this :

npm install react-router

What was installed by me is not consistent with almost all the tutorials I have read on the internet. One example : https://css-tricks.com/learning-react-router/

For a start, it is missing IndexRoute. Where is IndexRoute? I cannot seem to get any of my examples working.

Upvotes: 0

Views: 517

Answers (1)

Shubham Khatri
Shubham Khatri

Reputation: 281696

When you install a package like

npm install react-router

It installs the latest package that is available on the npm repository. If you see the package.json, you will have the version the React router to be 4.x.x which doesn't have IndexRoute

You should install v3.x.x

To do that, remove the entry for react-router from your package.json and delete the node_modules.

Now run

npm install 

followed by

npm install -S [email protected]

See the react-router v4.0.0 Docs

Upvotes: 2

Related Questions