Vivek Aasaithambi
Vivek Aasaithambi

Reputation: 929

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

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

above code is that I've written in my sample project. When I try to run this sample project, It throws error

There is already a collection named "products"

I've tried meteor reset. still I am facing same issue. I googled but got no proper solution. can anyone help me out?

Upvotes: 4

Views: 1449

Answers (1)

grahan
grahan

Reputation: 2408

I had the same issue the last days. I solved it using this part of my 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": ...

And i also deleted all .js and .js.map files from my working directory. As @KRONWALLED already mentioned, the problem is occuring when you use an IDE which is auto compiling your .ts files. When you are using the atom-typescript package it could be that this is autocompiling your .ts files. That's why you get this error. The important line in the tsconfig.json file is

"compileOnSave": false,

Here we declare that our compiler should not compile the file on save. Only when meteor is running, then the files get compiled with meteor.

I hope this will help you.

Upvotes: 2

Related Questions