6

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?

loganfsmyth
  • 156,129
  • 30
  • 331
  • 251
Kyle Decot
  • 20,715
  • 39
  • 142
  • 263
  • 1
    this issue was fixed by upgrading brunch to 2.2.3. seems like it had a bug that prevented loading some modules – kovpack Apr 08 '16 at 18:44
  • Hey Kyle, did you figure it out by any chance? – Andrea.cabral Jun 09 '16 at 15:20
  • @Andrea.cabral Unfortunately I did not but I didn't give the issue too much attention. I ended up using Webpack for my Elixir Phoenix application and it's been working perfectly. Hopefully at some point I can revisit it though. – Kyle Decot Jun 09 '16 at 15:36
  • Awesome, I guess I will do the same ;) thanks for answering back! – Andrea.cabral Jun 09 '16 at 17:51

1 Answers1

1

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.

ChristopherC
  • 1,635
  • 16
  • 31