Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using react-router w/ brunch/babel

I'm attempting use react-router in my brunch/babel setup. In my app.js I have:

import React from "react"
import ReactDOM from "react-dom"
import { Router, Route, Link } from "react-router"

This however gives me:

Uncaught Error: Cannot find module "history/lib/createHashHistory" from "react-router/Router"

When looking at the referenced line I see:

var _historyLibCreateHashHistory = require('history/lib/createHashHistory');

When inspecting the app.js that's generated via brunch I see:

require.register('history/createBrowserHistory', function(exports,req,module) {
  ...
});

How do I go about fixing this so that createBrowserHistory gets imported properly?

like image 844
Kyle Decot Avatar asked Jan 16 '16 05:01

Kyle Decot


Video Answer


1 Answers

The module history is listed as a peer dependency by react-router, which means that you need to install it yourself through the command npm install history --save.

like image 123
ChristopherC Avatar answered Sep 19 '22 22:09

ChristopherC