node.jsnpmnpm-packageliveservernpm-live-server

npm live-server doesn't refresh the page


live-server package by npm doesn't refresh (reload) the page when I change the CSS files.

It detects the changes for CSS files (in terminal) but doesn't refresh (in page).
vs code - terminal

PS E:\File\004> npx live-server
Serving "E:\File\004" at http://127.0.0.1:8080
Ready for changes
GET /favicon.ico 404 3.931 ms - 150
CSS change detected E:\File\004\style.css
CSS change detected E:\File\004\style.css

Other files are ok.
When I change other files, CSS files get update with them too. lol

I installed it locally and globally and it's still the same.
Is it because of package.json file or what?

{
  "dependencies": {
    "live-server": "^1.2.2"
  }
}

Thanks for helping.


Solution

  • LiveServer works by tricking your browser into injecting changes in CSS files. If that doesn't work you may have a browser problem.

    If you want live-server to reload the page on changes use this parameter when running live-server

    npx live-server --no-css-inject
    

    You can find more information here.

    https://www.npmjs.com/package/live-server