Angular2在本地开发中慢速自动刷新页面 – Windows

我是angular2的新手,并遵循docs的英雄教程。 我在angular2上遇到了相当慢的开发经验。 angular2需要大约5秒来检测文件中的变化,然后在30-40秒内重新加载页面。

[0] 8:08:12 PM - File change detected. Starting incremental compilation... [0] app/hero-detail.component.ts(2,8): error TS1192: Module '"app/app.component"' has no default export. [0] 8:08:16 PM - Compilation complete. Watching for file changes. [1][BS] File changed: app\app.component.js [1] [BS] File changed: app\hero-detail.component.js [1] [BS] File changed: app\main.js [1] 16.02.07 20:08:39 304 GET /./index.html (Unknown - 8551ms) [1] 16.02.07 20:08:45 304 GET /./index.html (Unknown - 1145ms) [1] 16.02.07 20:08:45 304 GET /node_modules/es6-shim/es6-shim.min.js (Unknown - 384ms) [1] 16.02.07 20:08:45 304 GET /node_modules/systemjs/dist/system-polyfills.js (Unknown - 393ms) [1] 16.02.07 20:08:45 304 GET /node_modules/angular2/bundles/angular2-polyfills.js (Unknown - 399ms) [1] 16.02.07 20:08:46 304 GET /node_modules/systemjs/dist/system.src.js (Unknown - 906ms) [1] 16.02.07 20:08:46 304 GET /node_modules/rxjs/bundles/Rx.js (Unknown - 911ms) [1] 16.02.07 20:08:47 304 GET /node_modules/es6-shim/es6-shim.min.js (Unknown - 962ms) [1] 16.02.07 20:08:47 304 GET /node_modules/systemjs/dist/system-polyfills.js (Unknown - 967ms) [1] 16.02.07 20:08:47 304 GET /node_modules/angular2/bundles/angular2.dev.js (Unknown - 972ms) [1] 16.02.07 20:08:47 304 GET /node_modules/angular2/bundles/angular2-polyfills.js (Unknown - 977ms) [1] 16.02.07 20:08:48 304 GET /node_modules/systemjs/dist/system.src.js (Unknown - 1429ms) [1] 16.02.07 20:08:48 304 GET /node_modules/rxjs/bundles/Rx.js (Unknown - 1431ms) 

虽然这一次看起来可能并不重要,但是当我不得不经常进行修改和检查输出时,它开始累加起来。

任何build议,为什么angular2是缓慢的发展.. ??

问题

问题不在于angular2,而在于Windows / Antivirus,因为它们是由于所谓的安全措施而减慢了node.js的速度。

  • 禁用Windows Defender(或任何其他防病毒软件)的实时防护,因为它会降低node.js的速度
  • 以pipe理员身份运行控制台(如果使用该控制台,请使用gitbash)
  • 使用SSD驱动器

终极解决scheme

性能和节点模块没有被安装的问题不断,迫使我彻底抛弃Windows 。 而我转移到mac的那一天,节点和angular度的发展经验更好,差别就像黑夜和阳光充沛,光彩灿烂的日子。

更多细节

阅读这个优秀的答案来获得更多的细节。

您也可以尝试让lite-server不监视您的node_modules目录。 看到这里的configuration说明: https : //github.com/johnpapa/lite-server

  • bs-config.json添加到您的项目中,并指定要监视重新加载的文件

     { "port": 8000, "files": ["./app/**/*.{html,htm,css,js}", "./*.{html,css,js,json}"], "server": { "baseDir": "./" } } 
  • 在config.json中将configuration文件添加到启动中

     { ... "scripts": { ... "lite": "lite-server -c bs-config.json",