Angular2 cli 生成"错误:尝试向现有条目添加新条目"



我使用Angular2Cli作为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身份运行与我的问题有关。

这是我的包.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"
  }
}

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

非常感谢。

如果您是windows用户,请在管理模式下运行您的终端。我也面临同样的问题,它对我有效:)

相关内容

  • 没有找到相关文章