Angular2 slow auto page refresh in local development - Windows
Problem
The problem was not with angular2, rather it was with Windows/Antivirus as they were slowing down node.js due to their so-called security measures.
Solution
- Disable realtime protection from windows defender (or any other antivirus), as it slows down node.js
- Run console (or gitbash if you use that) as an administrator
- Use SSD drive
Ultimate Solution
The constant problems of performance and node modules not being installed, forced me to completely ditch Windows. And the day I shifted to mac, node and angular development experience was WAY better, the difference was like dark-night and full-sunny-shiny-broady-day.
More details
Read this excellent answer to get more details.
You can also try to have lite-server
not monitor your node_modules
directory. See here for config instructions: https://github.com/johnpapa/lite-server
Add a
bs-config.json
to your project and specify files to watch for a reload{ "port": 8000, "files": ["./app/**/*.{html,htm,css,js}", "./*.{html,css,js,json}"], "server": { "baseDir": "./" } }
Add the config file to your startup in
packages.json
{ ... "scripts": { ... "lite": "lite-server -c bs-config.json",