I watch a video on youtube and the creator created a simple HTML js project after that he just run it in the terminal of vs Code. I search about this on youtube and google but I can't understand it. If someone how have any idea to do that I'll be grateful. thank you.
CodePudding user response:
You should get help from Node.js ecosystem!
Install Node.js LTS version from official website! (node.js website)
Install live-server package(live-server website) globally
Go to the directory where the project is.
~ cd path/to/project
Then just run
~ live-server
CodePudding user response:
You can use a VSCODE extension for localhosting your static files. Its called Liveserver.
CodePudding user response:
You can use nodejs, but you can't use some javascript keywords and methods which run on the browser like document
addEventListener
(but we have on
method). Because node is built for server-side applications, there is no document
on the server.
If you are working on a frontend application, there are many packages you can use, like
- serve (
npm install -g serve
) - live server (
npm install -g live-server
) - webpack