Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

npm live-server not auto-reloading

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"
}
like image 801
Abul Khoyer Avatar asked Jul 15 '18 07:07

Abul Khoyer


People also ask

Why is my live server not refreshing?

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.

How do I run Liveserver?

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.

What is a live 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+).


1 Answers

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>
like image 129
Gnopps Avatar answered Oct 24 '22 05:10

Gnopps