Sunday, December 29, 2019

Debug VS Code HTML5, CSS3 and JavaScript using npm http-server

Prerequisites tools needed:
  1. Windows 10
  2. VS Code - https://code.visualstudio.com/
  3. Node and NPM - https://www.npmjs.com/get-npm

Setup git Code repository:
  1. Setup folder for your project as for my preference I use
    C:\Users\moojjoo\Source\Repos\[SolutionFolder]
  2. I am a big advocate of git source control - https://git-scm.com/ and the great part is that it is packaged with VS Code so once you have your files setup be sure to
    1. git add .
    2. git commit -m 'Initial Commit'



// Using Terminal BASH run
npm install http-server -g
http-server ./


As a result you will get the url to run and debug your JavaScript 


// Once successfully running the code you can then create .vscode/lauch.json and 
// update the highlight code.  The great part with running npm http-server ./  
// All changes are updated and reflected in the browser
{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, 
    // visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "type": "chrome",
            "request": "launch",
            "name": "Launch Chrome against localhost",
            "url": "http://127.0.0.1:8080",
            "webRoot": "${workspaceFolder}"
        }
    ]
}

No comments: