3
votes

I am new to Angular and hence Visual Studio Code. I started with my first Angular application by following online tutorial. When I tried to execute http-server on VS code integrated terminal, I got the below error. I could not find, how to resolve.

PS C:\MyFolder\Learning\Angular> http-server http-server : The term 'http-server' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:1 + http-server + ~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (http-server:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException

4

4 Answers

8
votes

Run this from within the terminal:

npm install -g http-server

What this will do is install the latest version of http-server globally on your computer. Then you can run it from the terminal, or another command prompt, when you need to serve a web application.

See this for more information on the package, and how to use it.

1
votes

Have you installed it globally?

npm i -g http-server

To be able to use a package in your terminal you need to have it installed globally on your machine.

1
votes

HI I got the same error but I fix it work also for when you use live server ---> In your visual studio code editor click here for image

press icon shown in the image and then install HTTP-server/live-server now open your HTML file as for right click on the file and select option open as live-server . now it's fine...

THANKS----

0
votes

you can install with this:

npm install http-server