not found using http-server node.js

1.6k views Asked by At

I install http-server globally and still failed to load my angular app. I can start by doing http-server C:\Users\Alex\Desktop\angularjsTDD\app but when I visit localhost:8080 the terminal has a not found error message. The structure of my app can be found in githib

https://github.com/eldyvoon/angularTDD

Previously I was using express as backend but I want to try to use something simpler, but failed to get it to work.

If I visit index.html without using http-server like file:///C:/Users/Alex/Desktop/angularjs%20TDD/app/index.html I got error of Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https, chrome-extension-resource. in chrome.

2

There are 2 answers

0
nigeljohnwade On

If you are trying to serve static files I think you need to place a folder called public in the directory you are serving from. Soi in your structure create a folder called public and put all of your files in there. Serving app should then load index.html from the public folder.

0
Jessie Emerson On

I was using some path starting http-server which was wrong.

I've found the solution. The correct workaround would be

cd into my project, run http-server.