Javascript Angular2本地开发中的慢速自动页面刷新-Windows

Javascript Angular2本地开发中的慢速自动页面刷新-Windows,javascript,node.js,typescript,angular,Javascript,Node.js,Typescript,Angular,我是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"' ha

我是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)
虽然这段时间似乎并不重要,但当我必须定期进行更改并检查输出时,它开始累积起来

关于angular2开发缓慢的原因,有什么建议吗?

问题 问题不在于angular2,而在于Windows/Antivirus,因为他们所谓的安全措施降低了node.js的速度

解决方案
  • 禁用windows defender(或任何其他防病毒软件)的实时保护,因为其速度会减慢 node.js
  • 以管理员身份运行console(或者gitbash,如果您使用它的话)
  • 使用SSD驱动器
最终解 不断出现的性能问题和未安装节点模块的问题迫使我彻底抛弃Windows。在我换到mac的那天,节点和角度的开发体验要好得多,差别就像黑夜和阳光充足的大白天

更多细节
阅读此内容以获取更多详细信息。

您也可以尝试让
lite服务器
不监视您的
节点模块
目录。有关配置说明,请参见此处:

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

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

    {
      ...
      "scripts": {
        ...
        "lite": "lite-server -c bs-config.json",
    
您可以运行project add--aot参数,例如

ng serve --aot

为什么有人否决了我的问题。。。???我正在开发angular2应用程序,开发过程中的性能太慢,我想找到一种加速的方法……抛弃windows显然可以解决所有问题。它让我妻子回来了。