I don't know if this is good place to ask this question but i just started studying reactjs and stuck in the beginning, here is the question.
I have installed node and Installed http-server
from the npm
command on the command prompt npm install -g http-server
and went to the directory where is my static files and run command http-server
and then to the browser hit localhost:8081
.
Nothing happens/shows on browser but on command prompt it shows that its running and working properly, everytime i refresh browser then it shows on command prompt working. So why nothing happens on browser ?
here is the code:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1 maximum-scale=1">
<title>Demo</title>
<script src="https://unpkg.com/react@16/umd/react.production.min.js"></script>
<script src="https://unpkg.com/react-dom@16/umd/react-dom.production.min.js"></script>
<script src="https://unpkg.com/babel-standalone@6.15.0/babel.min.js"></script>
</head>
<body>
<div id="example">
</div>
<script type="text/babel">
ReactDOM.render(
<h1>Something</h1>, document.getElementById('example'));
</script>
</body>
</html>
It looks like there is an ongoing issue with http-server
. However, we can fix this using this tweak.
Try accessing your file in localhost with the filename after running http-server
command.
For example, if your file name is somefile.html
, try accessing this file like http://localhost:8081/somefile.html