angular 2 + meteor 中已经有一个名为 "collection" 的集合

There is already a collection named "collection" in angular 2 + meteor

import {Mongo} from 'meteor/mongo'; export let Products = new Mongo.Collection('products');

以上代码是我在示例项目中编写的。当我尝试 运行 这个示例项目时,它抛出错误

There is already a collection named "products"

我试过了meteor reset。我仍然面临同样的问题。我用谷歌搜索但没有找到合适的解决方案。谁能帮帮我?

前几天我遇到了同样的问题。我使用 tsconfig.json

的这一部分解决了它
"atom": {
    "rewriteTsconfig": true
  },
  "compileOnSave": false,
  "buildOnSave": false,
  "compilerOptions": {
    "experimentalDecorators": true,
    "module": "commonjs",
    "target": "es5",
    "isolatedModules": false,
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "removeComments": false,
    "noImplicitAny": false,
    "sourceMap": true
  },
  "filesGlob": ...

而且我还从我的工作目录 中删除了所有 .js 和 .js.map 文件。正如@KRONWALLED 已经提到的,当您使用自动编译 .ts 文件的 IDE 时会出现问题。当您使用 atom-typescript 包 时,这可能是自动编译您的 .ts 文件。这就是您收到此错误的原因。 tsconfig.json 文件中重要的一行是

"compileOnSave": false,

在这里我们声明我们的编译器不应该在保存时编译文件。只有当 meteor 是 运行 时,文件才会用 meteor 编译。

希望对您有所帮助。