The problem is browser can't show JavaScript file as result. You should use in command the folder with index.html. (If you mention index.html, it will also download)
The typical usage is:
http-server
which is equivalent to http-server "./"
. Comments above mention Content-Type
. That's because of HTTP protocol and the fact, the package is not perfect. For you, try to use HTML.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…