dvdzkwsk / react-redux-starter-kit

Get started with React, Redux, and React-Router.
MIT License
10.29k stars 2.2k forks source link

After koa refactor, webpack can't find `webpack-hot-middleware` #399

Closed kaptron closed 8 years ago

kaptron commented 8 years ago

Hey guys, awesome project and I had gotten everything up and running last week, and then was curious about merging in the latest updates with the koa refactor in #389, and am now running into the following error on npm start:

ERROR in multi app
Module not found: Error: Cannot resolve module 'webpack-hot-middleware/client' in /projects/ReduxStarterApp
 @ multi app

Seems to be the same issue referenced in koa-webpack-hot-middleware here: https://github.com/dayAlone/koa-webpack-hot-middleware/issues/1

However it seems a little silly to use the solution proposed there, which is just to include webpack-hot-middleware as a dev dependency (perhaps defeating the purpose of using koa-webpack-hot-middleware in the first place?), although this did fix the issue for me.

Just to double check, this also happens for me if I git clone this repo from scratch and run npm install. FYI I'm using Node v5.0.0 on Mac OSX 10.11.1 (El Capitan).

dvdzkwsk commented 8 years ago

Hey, can you try checking out this commit: https://github.com/davezuko/react-redux-starter-kit/commit/e708c5202ef2e7b310757056294e24f230972e6a and see if that works for you? I didn't reinstall my node_modules from scratch after testing so that could be why I didn't catch it. If this works I'll probably just revert back to using local middleware definitions.

kaptron commented 8 years ago

Hmm, I already had those node/npm settings in my package.json. Although I can say (hopefully without going down a totally different rabbit hole here) that I'm using npm 2.14.2 and not 3.0+. I do have npm 3.5.2 installed as a separate command npm3, however when I install this project with npm3 install and then npm3 start, I get a different set of errors around babel-preset-react-hmre, with all of the React components, e.g.

ERROR in ./src/containers/Root.js
Module not found: Error: Cannot resolve 'file' or 'directory' /projects/ReduxStarterApp/node_modules/babel-preset-react-hmre/node_modules/redbox-react/lib/index.js in /projects/ReduxStarterApp/src/containers
 @ ./src/containers/Root.js 29:13-139

And surely enough I can see that there is no node_modules subdirectory within node_modules/babel-preset-react-hmre so clearly something is not getting configured properly re: npm 3's flat install structure. Anyway, as a result I've stuck with npm 2.14.2 which otherwise seems to work fine for me (other than this latest snag w/ koa middleware).

dvdzkwsk commented 8 years ago

Yeah you'll keep getting that error w/ npm2 unless you declare all of those babel dependencies locally, it's unfortunate :(. Same goes for eslint.

kaptron commented 8 years ago

Gotcha. Well, thanks for following up! I'm just continuing with npm2 and including webpack-hot-middleware, works for me.

rsilvestre commented 8 years ago

@davezuko it's not better to update koa-webpack-hot-middleware and use that dependency instead of implementing it in this starterkit?

dvdzkwsk commented 8 years ago

@rsilvestre yeah that would work, I've been incredibly tied up lately though so I didn't really want to miss anything else in case there was some other unknown problem. Once I have a chance to sit down and look at the kit again I'll definitely revert back to the implementation you provided in the PR.

It was more of a panic "oh shit, this might be broken on master for a bunch of people" revert-to-an-old-commit than anything.

rsilvestre commented 8 years ago

:+1:

dvdzkwsk commented 8 years ago

Closing this since the issue is fixed, but will submit a PR @rsilvestre when I get some time.