1

Angular 2 アプリケーションのランタイム環境としてAngular2 Cliを使用しています。そのアーキテクチャ、クラス最高の開発ツール、そして全体的に考え抜かれた(これ以上の言葉はありませんが) ことに、私は本当に感銘を受けました。

ただし、約 5 回の保存 (ビルド) ごとに、サーバーでエラー メッセージが生成されます。

Error: Trying to add a new entry to an already existing one:

次に、プロセスを強制終了して再起動し、問題を回避する必要があります。

全文は次のとおりです。

file changed app/vtClass.ts
The Broccoli Plugin: [BroccoliTypeScriptCompiler] failed with:
Error: Trying to add a new entry to an already existing one: /home/vturner/vtstuff/angular/projects/ang2-cli2/tmp/broccoli_type_script_compiler-input_base_path-sdRX1KMo.tmp/0/src/app/ang2-cli2.spec.ts
    at BroccoliTypeScriptCompiler._addNewFileEntry (/home/vturner/vtstuff/angular/projects/ang2-cli2/node_modules/angular-cli/lib/broccoli/broccoli-typescript.js:212:13)
    at /home/vturner/vtstuff/angular/projects/ang2-cli2/node_modules/angular-cli/lib/broccoli/broccoli-typescript.js:159:38
    at Array.forEach (native)
    at BroccoliTypeScriptCompiler._doFullBuild (/home/vturner/vtstuff/angular/projects/ang2-cli2/node_modules/angular-cli/lib/broccoli/broccoli-typescript.js:159:16)
    at BroccoliTypeScriptCompiler._doIncrementalBuild (/home/vturner/vtstuff/angular/projects/ang2-cli2/node_modules/angular-cli/lib/broccoli/broccoli-typescript.js:116:12)
    at BroccoliTypeScriptCompiler.build (/home/vturner/vtstuff/angular/projects/ang2-cli2/node_modules/angular-cli/lib/broccoli/broccoli-typescript.js:45:12)
    at /home/vturner/vtstuff/angular/projects/ang2-cli2/node_modules/broccoli-caching-writer/index.js:152:21
    at lib$rsvp$$internal$$tryCatch (/home/vturner/vtstuff/angular/projects/ang2-cli2/node_modules/rsvp/dist/rsvp.js:1036:16)
    at lib$rsvp$$internal$$invokeCallback (/home/vturner/vtstuff/angular/projects/ang2-cli2/node_modules/rsvp/dist/rsvp.js:1048:17)
    at lib$rsvp$$internal$$publish (/home/vturner/vtstuff/angular/projects/ang2-cli2/node_modules/rsvp/dist/rsvp.js:1019:11)

The broccoli plugin was instantiated at: 
    at BroccoliTypeScriptCompiler.Plugin (/home/vturner/vtstuff/angular/projects/ang2-cli2/node_modules/broccoli-plugin/index.js:10:31)
    at BroccoliTypeScriptCompiler.CachingWriter [as constructor] (/home/vturner/vtstuff/angular/projects/ang2-cli2/node_modules/broccoli-caching-writer/index.js:21:10)
    at BroccoliTypeScriptCompiler (/home/vturner/vtstuff/angular/projects/ang2-cli2/node_modules/angular-cli/lib/broccoli/broccoli-typescript.js:25:35)
    at Angular2App.toTree (/home/vturner/vtstuff/angular/projects/ang2-cli2/node_modules/angular-cli/lib/broccoli/angular2-app.js:67:16)
    at module.exports (/home/vturner/vtstuff/angular/projects/ang2-cli2/angular-cli-build.js:11:14)
    at Class.module.exports.Task.extend.setupBroccoliBuilder (/home/vturner/vtstuff/angular/projects/ang2-cli2/node_modules/angular-cli/node_modules/angular-cli/lib/models/builder.js:55:19)
    at Class.module.exports.Task.extend.init (/home/vturner/vtstuff/angular/projects/ang2-cli2/node_modules/angular-cli/node_modules/angular-cli/lib/models/builder.js:89:10)
    at new Class (/home/vturner/vtstuff/angular/projects/ang2-cli2/node_modules/core-object/core-object.js:18:12)
    at Class.module.exports.Task.extend.run (/home/vturner/vtstuff/angular/projects/ang2-cli2/node_modules/angular-cli/node_modules/angular-cli/lib/tasks/serve.js:15:19)
    at /home/vturner/vtstuff/angular/projects/ang2-cli2/node_modules/angular-cli/node_modules/angular-cli/lib/commands/serve.js:70:22

コーディング エラーが発生した場合にのみ問題が発生するようですが、コーディング エラーとこのメッセージが 1 対 1 で対応しているわけではありません。私が生成するほとんどのコーディング エラーでは、このメッセージは生成されませ

エラーが発生すると、サーバーはブロックされた状態になり、コーディングの問題を修正するなど、何をしても問題は解決しないようです。サーバーを循環させたときにのみ消えます。
これを修正するために、この状態をチェックしてサーバーを循環させる必要があり、これには約 6 秒かかります。

コードを投稿することはできますが、コードとこのメッセージの取得の間に韻や理由が見当たらないため、これは役に立たないと思います。つまり、これは環境の問題であり、コーディングの問題ではないと思います。エラー メッセージに記載されている tmp ディレクトリを削除しようとしましたが、うまくいきませんでした。

サーバーを次のように起動します。

vturner@vturner-virtual-machine ~/vtstuff/angular/projects/ang2-cli2 $ 
sudo ng serve 
Could not start watchman; falling back to NodeWatcher for file system events.
Visit http://www.ember-cli.com/user-guide/#watchman for more info.
Livereload server on http://localhost:49152
Serving on http://localhost:4200/

Build successful - 8049ms.

Slowest Trees                                 | Total               
----------------------------------------------+---------------------
BroccoliTypeScriptCompiler                    | 7643ms              

Slowest Trees (cumulative)                    | Total (avg)         
----------------------------------------------+---------------------
BroccoliTypeScriptCompiler (1)                | 7643ms              

file changed app/vtClass.ts

Build successful - 1072ms.

注: サーバーを sudo として実行してきました。これは、パーミッションに問題があるか、sudo として高速に実行されることをどこかで読んだためです (この最後のものは Windows でのみ当てはまる可能性があります) が、sudo として実行しているとは思いません。私の問題に関連しています。

これが私のpackage.jsonです:

{
  "name": "ang2-cli2",
  "version": "0.0.0",
  "license": "MIT",
  "angular-cli": {},
  "scripts": {
    "start": "ng server",
    "postinstall": "typings install --ambient",
    "lint": "tslint src/**/*.ts",
    "format": "clang-format -i -style=file --glob=src/**/*.ts",
    "pree2e": "webdriver-manager update",
    "e2e": "protractor"
  },
  "private": true,
  "dependencies": {
    "angular2": "2.0.0-beta.11",
    "es6-shim": "^0.35.0",
    "reflect-metadata": "0.1.2",
    "rxjs": "5.0.0-beta.2",
    "systemjs": "0.19.20",
    "three": "^0.75.0",
    "zone.js": "^0.6.4"
  },
  "devDependencies": {
    "angular-cli": "0.0.*",
    "angular-cli-github-pages": "^0.2.0",
    "clang-format": "^1.0.35",
    "codelyzer": "0.0.12",
    "ember-cli-inject-live-reload": "^1.4.0",
    "jasmine-core": "^2.3.4",
    "jasmine-spec-reporter": "^2.4.0",
    "karma": "^0.13.15",
    "karma-chrome-launcher": "^0.2.1",
    "karma-jasmine": "^0.3.6",
    "protractor": "^3.0.0",
    "ts-node": "^0.5.5",
    "tslint": "^3.6.0",
    "typescript": "^1.8.7",
    "typings": "^0.6.6"
  }
}

私が間違っていること、またはこれを防ぐために何ができるかを誰かに教えてもらえますか?

どうもありがとう。

4

1 に答える 1