Amin Jafari Amin Jafari - 1 month ago 31
React JSX Question

react-router tutorial not working on mac

I tried to get into react following the react tutorials and got it working, but when I started to go to the next step and use react-router through this tutorial I failed every time!

When I follow the instructions everything seems to be working OK, no errors on terminal, but I don't see any bundle.js files created in my project folder nor the localhost:8080 shows anything other than the following error in console:


GET http://localhost:8080/ net::ERR_EMPTY_RESPONSE


I tried installing npm locally and globally but none worked, same as webpack. Also I tried running the servers using webpack with the code
webpack ./index.js bundle.js
doesn't work either and throws the following error in terminal:


ERROR in multi main
Module not found: Error: Cannot resolve module 'bundle.js' in /Users/jafari/Desktop/React-Toturial/react-router-tutorial/lessons/01-setting-up
@ multi main


While this code creates the bundle.js file and if I run this folder through MAMP on the localhost I can see the desired content of the tutorial, when I change anything in the App.js it doesn't take effect until I remove the bundle.js and do the process I mentioned earlier again in the terminal while still seeing the following error in the console:


bundle.js:49 Uncaught Error: Cannot find module "bundle.js"


And if I don't remove bundle.js I get this error in the console:


Warning: React attempted to reuse markup in a container but the checksum was invalid. This generally means that you are using server rendering and the markup generated on the server was not what the client was expecting. React injected new markup to compensate which works but you have lost many of the benefits of server rendering. Instead, figure out why the markup being generated is different on the client or server:(client)
<div data-reactid="
(server)
<div data-reactid="



Any ideas? or alternatively any suggestion or tutorial on how to use react-router?

Answer

Try to change the port to something else with the command webpack-dev-server --port 3000 --inline --content-base

You can also substitute the npm start script in the package.json with that line.

Comments