简体   繁体   中英

node HTTP-Server is not working properly?

when i install http-server in c: drive it install automatically in d: drive.

here is the result:-

C:\Users\Kuncham>npm install http-server -g
D:\usr\local\http-server -> D:\usr\local\node_modules\http-server\bin\http-server
D:\usr\local\hs -> D:\usr\local\node_modules\http-server\bin\http-server
+ http-server@0.11.1
updated 1 package in 1.131s

after installation when i run http-server in my project folder it will start the http-server and also we can access the link given in command prompt. the browser will show only files not run the my angular application. 在此处输入图片说明

  1. Install http-server using npm install -g http-server command
  2. Generate a build by using ng build --prod command
  3. Go to dist/project_name from cmd
  4. Type http-server -p 8080 on cmd
  5. Type http://localhost:8080/ on browser

Perform an ng build on the directory and point your http-server at the resulting dist/ folder, which contains the compiled HTML and Javascript files your browser can consume.

More information: Angular - Deployment

I just installed http-server today and my problem was it just wasn't serving the content at all when I went to localhost:8080. The command prompt would flash for a second and disappear. I resolved my problem by hitting http://192.168.40.78:8080 . http-server lists two urls you could hit. The 192 one worked, but not the localhost one.

specify the file when running http-server

http-server [path] [options]

[path] defaults to ./public if the folder exists, and ./ otherwise.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM