Search code examples
node.jsnpmhttpserver

Visual Studio Code Integrated Terminal: http-server : The term 'http-server' is not recognized


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


Solution

  • 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.