I have tried to work on the live server, installed a node package called live-server
by using this command: npm install -g live-server
It worked fine, installed successfully and run live-server
by live-server
command.
Whenever I change my code and save on code editor, the browser won't refresh automatically.
Here is my package.json
file:
"name": "nodejs",
"version": "1.0.0",
"description": "",
"main": "app.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "Abul Khoyer",
"license": "ISC"
}
Just uncheck the option “Use Web Ext”. close your visual studio code. Open it again and your live server works fine by auto reloading. Check your path.
Shortcuts to Start/Stop ServerOpen a HTML file and right-click on the editor and click on Open with Live Server . Open the Command Pallete by pressing F1 or ctrl+shift+P and type Live Server: Open With Live Server to start a server or type Live Server: Stop Live Server to stop a server.
Live Server - Makes your existing server live - this is a Web Extension that helps you to live reload feature for dynamic content (PHP, Node.js, ASPNET -- Whatever, it doesn't matter). This extension is for Live Server (VSCode Extension - required v3.0.0+).
I had the same problem as you and managed to get it working by making sure that the .html-file was properly formatted. I.e. like this:
<!DOCTYPE html>
<html>
<body>
<h1>Script tester!</h1>
<script type="text/javascript" src="script.js"></script>
</body>
</html>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With