Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Meteor Error: A method named insert is already defined

I had created a mongo collection named votes Which was working properly even after updating the packages to latest meteor version. I don't remember changing any part of the working code however I am getting this errors. I had updated the project using meteor update command and tested it right after the update. It ran successfully that time but I have no clue why I'm getting this error. And, not sure which source file should I add to get help...

Can anyone shed some light?

W20141025-21:29:08.640(6)? (STDERR) 
W20141025-21:29:08.641(6)? (STDERR) /home/wasi/.meteor/packages/meteor-tool/.1.0.34.k7p01x++os.linux.x86_32+web.browser+web.cordova/meteor-tool-os.linux.x86_32/dev_bundle/lib/node_modules/fibers/future.js:173
W20141025-21:29:08.641(6)? (STDERR)                         throw(ex);
W20141025-21:29:08.642(6)? (STDERR)                               ^
W20141025-21:29:08.693(6)? (STDERR) Error: A method named '/votes/insert' is already defined
W20141025-21:29:08.695(6)? (STDERR)     at packages/ddp/livedata_server.js:1439
W20141025-21:29:08.696(6)? (STDERR)     at Function._.each._.forEach (packages/underscore/underscore.js:113)
W20141025-21:29:08.697(6)? (STDERR)     at _.extend.methods (packages/ddp/livedata_server.js:1437)
W20141025-21:29:08.697(6)? (STDERR)     at Mongo.Collection._defineMutationMethods (packages/mongo/collection.js:884)
W20141025-21:29:08.698(6)? (STDERR)     at new Mongo.Collection (packages/mongo/collection.js:208)
W20141025-21:29:08.699(6)? (STDERR)     at app/collections/collection.js:1:43
W20141025-21:29:08.700(6)? (STDERR)     at app/collections/collection.js:58:3
W20141025-21:29:08.701(6)? (STDERR)     at /home/wasi/AI/OVS/.meteor/local/build/programs/server/boot.js:168:10
W20141025-21:29:08.702(6)? (STDERR)     at Array.forEach (native)
W20141025-21:29:08.702(6)? (STDERR)     at Function._.each._.forEach (/home/wasi/.meteor/packages/meteor-tool/.1.0.34.k7p01x++os.linux.x86_32+web.browser+web.cordova/meteor-tool-os.linux.x86_32/dev_bundle/lib/node_modules/underscore/underscore.js:79:11)
=> Exited with code: 8
=> Your application is crashing. Waiting for file change.
[=================== ] 94% 4.8s
like image 961
Wasi Avatar asked Oct 25 '14 17:10

Wasi


1 Answers

Please note: If you are currently using the Angular-Meteor tutorial to build the app Socially and you are using an integrated development environment (IDE) like WebStorm, which is able to automatically compile TypeScript to JavaScript, my answer will probably help you to solve this problem.


I received this error without redefining a collection. Later I found out that my IDE (WebStorm 2016.1) caused duplicates, because it automatically compiled TypeScript to JavaScript even though Meteor handles this job for us. Luckily I got rid of this error by just disabling the TypeScript Compiler in WebStorm and deleting the compiler output files.

So, if WebStorm asks you if you want to compile TypeScript to JavaScript, say No!

WebStorm - Compile TypeScript to JavaScript

If you have already messed up your setup, go to WebStormPreferencesLanguages & FrameworksTypeScript and uncheck the "Enable TypeScript Compiler" option:

TypeScript Compiler in WebStorm Preferences

After that, delete the TypeScript compiler output files:

WebStorm TypeScript Compiler Output

Now your application should work again. Happy coding!

like image 105
Matthias A. Eckhart Avatar answered Oct 11 '22 22:10

Matthias A. Eckhart