How to Run a HTML File from Terminal

How to run html file on localhost?

You can use python -m http.server. By default the local server will run on port 8000. If you would like to change this, simply add the port number python -m http.server 1234

If you are using python 2 (instead of 3), the equivalent command is python -m SimpleHTTPServer

How to run html & javascript in VS Code

You can install the following extensions.

  1. Live Server.
  2. Chrome Debugger.

Once you have these two extensions installed, open the page index.html using the live server and then press F12 to open the developer tools for chrome.

And then you can paste a single line of code on the debugger like this.

document.querySelector('button').addEventListener('click',()=>{
console.log("Event Raised");
};

How do I generate an html file with ejs in command line?

This is because ejs executable is not in your $PATH but in node_modules/.bin directory and shell couldn't find it.

Use npm'x exec command to run binaries provided with packages:

npm exec -- ejs ./template_file.ejs -o ./output.html

Or with an alias:

npx ejs ./template_file.ejs -o ./output.html


Related Topics



Leave a reply



Submit