I have installed http-server using the following command:
npm i -g http-server
Upon running the server I get the response saying Running o
I changed http-server version 0.10.0 to 0.8.5 in the package.json file and it worked for me. I hope this helps someone.
Try downgrading the http-server version as the latest version (0.10.0 and 0.11.0) is causing issue due to ecstatic (3.3.2).
Try uninstalling the current http-server version and then try to install 0.9.0 or older version
Uninstall
npm uninstall -g http-server
Install
npm install http-server@0.9.0
I'm having the exact same problem. Just installed both node and http-server globally. run http-server
and it gives me the following error when accessing localhost:8080:
"ERR_INVALID_REDIRECT"
If I try to access the index.html page
, it works. It doesn't even show directories listing, even with -d
in the command line.
I got something, though: installing an older version of http-server
and it loads the index.html
automagically :)
This was the command/version: npm install -g http-server@0.8.5
Anything newer (0.9.0+) and it breaks again.
Edit:
Even then, it will only work on sub-folders, not on the root. For example:
http://localhost:8080/mypage/ will load index.html automatically.
http://localhost:8080/ won't
This issue is fixed in version 0.12.0, make sure you're upgraded by running
npm install --global http-server
If you use npx http-server
it should use the latest version automatically.
pass url "0.0.0.0" when you are creating server and then try.
This is still an open issue with http-server, which is supposedly caused by the latest version of one http-server's dependencies called ecstatic:
https://github.com/http-party/http-server/issues/525
There are three workarounds for this at the point:
Point the browser to localhost:8080/index.html instead of just http://localhost:8080.
Downgrade your http-server version to 0.9 from 10.0
npm uninstall -g http-server
npm install http-server@0.9.0
Open package.json file under the http-server module and downgrade ecstatic dependency
to 3.3.1 (found under 'dependencies' key).