Angular2 cli生成'错误:尝试向已存在的条目添加新条目'

时间:2016-04-06 23:18:57

标签: angularjs angular broccolijs angular-cli

我正在使用Angular2 Cli作为Angular 2应用程序的运行时环境。我对它的体系结构,最好的开发工具以及整体精心设计的(缺乏更好的词)给我留下了深刻的印象。

但是,大约每五次保存(构建)我的服务器都会生成错误消息:

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"
  }
}

有谁能告诉我我做错了什么,或者我能做些什么来防止这种情况?

非常感谢。

1 个答案:

答案 0 :(得分:4)

如果您是Windows用户,请在管理模式下运行终端。我遇到了同样的问题,它对我有用:)