Meteor with Angular2 Error

I’m following the tutorial with angular2, on step 3 I get the error above.

Anybody can help me?

Error
=> Exited with code: 8
=> Your application is crashing. Waiting for file change.
=> Modified – restarting.
W20160527-18:16:12.901(-3)? (STDERR)
W20160527-18:16:12.901(-3)? (STDERR) /Users/rodrigocastilho/.meteor/packages/meteor-tool/.1.3.2_4.lbyo5v++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/dev_bundle/server-lib/node_modules/fibers/future.js:267
W20160527-18:16:12.901(-3)? (STDERR) throw(ex);
W20160527-18:16:12.901(-3)? (STDERR) ^
W20160527-18:16:13.210(-3)? (STDERR) Error: A method named ‘/parties/insert’ is already defined
W20160527-18:16:13.210(-3)? (STDERR) at packages/ddp-server/livedata_server.js:1548:15
W20160527-18:16:13.210(-3)? (STDERR) at Function..each..forEach (packages/underscore/underscore.js:113:1)
W20160527-18:16:13.210(-3)? (STDERR) at Server.methods (packages/ddp-server/livedata_server.js:1544:7)
W20160527-18:16:13.211(-3)? (STDERR) at packages/allow-deny/allow-deny.js:191:24
W20160527-18:16:13.211(-3)? (STDERR) at [object Object].CollectionPrototype._defineMutationMethods (packages/allow-deny/allow-deny.js:190:5)
W20160527-18:16:13.211(-3)? (STDERR) at new Mongo.Collection (packages/mongo/collection.js:226:8)
W20160527-18:16:13.211(-3)? (STDERR) at meteorInstall.collections.parties.js (collections/parties.ts:3:22)
W20160527-18:16:13.212(-3)? (STDERR) at fileEvaluate (packages/modules-runtime/.npm/package/node_modules/install/install.js:141:1)
W20160527-18:16:13.212(-3)? (STDERR) at require (packages/modules-runtime/.npm/package/node_modules/install/install.js:75:1)
W20160527-18:16:13.212(-3)? (STDERR) at server/main.ts:4:29

client/app.ts

import { Component, NgZone } from '@angular/core';
import { bootstrap }         from 'angular2-meteor-auto-bootstrap';
import { Parties }           from '../collections/parties';
import { Mongo }             from 'meteor/mongo';

@Component({
  selector: 'app',
  templateUrl: 'client/app.html'
})
class Socially {

  parties: Mongo.Cursor<Object>;

  constructor() {
    this.parties = Parties.find();
  }
}

bootstrap(Socially);

collections/parties.ts

import {Mongo} from 'meteor/mongo';

export let Parties = new Mongo.Collection('parties');

I have the same error … I got all the way to step 7 before it appeared.

I went through all the steps successfully earlier this week.

I believe your missing these lines on the top of app.ts

import 'reflect-metadata';
import 'zone.js/dist/zone';

I’ve uploaded a working copy of Step04 here: https://github.com/cesargalindo/socially-step04

I went through all the steps successfully earlier this week.

Here’s a working copy of Step07 here: https://github.com/cesargalindo/socially-step07

@cesargalindo THANK YOU very much. Yours runs great mine still crashes during build with the

A method named '/parties/insert' is already defined

The main source files are the same … I’ll go through the project with a diffing tool to see what I can find.

thanks again!

Tank you guys, but my app keep crashing after add lines.
The working copy you uploaded reflect the same problem, i believe that is a problem with my meteor installation or dependencies.
I’m trying to reinstall everything and starts again.

I figured it out!

If I manually delete the .js and .map files in the collections and client folders the app builds.

Here is the broken project and how to repro and fix the issue:

https://github.com/stocksp/socially-step-07-broken

@cesargalindo thanks again for your repo … I could not have fixed this without it.

Is there a way to force Meteor to ‘really’ rebuild itself for the .ts files ?

Thanks @stocksp, deleting .js and .map files in the collections makes app working fine.

Does it make sense?

Saving collection generate .js and .map, and app crashes again.

I’m not sure what exactly is going on other than its obvious on my machine that the Meteor build system is not working correctly and is allowing stale/toxic js to be cached and used, which caused the build to fail.
The error was that the parties collection method was showing up twice.
If you cloned @cesargalindo step seven GitHup repo he posted above AND that crashed the build system then I’m stumped.

Sounds like you have a TypeScript auto compiler running, probably in your editor. You should let meteor handle all the typescript compiles.

1 Like