简体   繁体   English

流星错误:已定义名为insert的方法

[英]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. 我创建了一个名为votes的mongo集合,即使在将软件包更新到最新的流星版本之后也能正常工作。 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. 我使用meteor 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

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. 请注意:如果您当前使用的角流星 教程构建应用程序在社交场合 ,你使用的是集成开发环境(IDE),如WebStorm ,它能够自动编译打字稿为JavaScript,我的回答可能会帮你解决这个问题。


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. 后来我发现我的IDE(WebStorm 2016.1)导致重复,因为它自动将TypeScript编译为JavaScript,即使Meteor为我们处理这项工作。 Luckily I got rid of this error by just disabling the TypeScript Compiler in WebStorm and deleting the compiler output files. 幸运的是,通过在WebStorm中禁用TypeScript编译器并删除编译器输出文件,我摆脱了这个错误。

So, if WebStorm asks you if you want to compile TypeScript to JavaScript, say No ! 因此,如果WebStorm询问您是否要将TypeScript编译为JavaScript,请说“ 不”

WebStorm  - 将TypeScript编译为JavaScript

If you have already messed up your setup, go to WebStormPreferencesLanguages & FrameworksTypeScript and uncheck the "Enable TypeScript Compiler" option: 如果您已经搞砸了设置,请转到WebStorm首选项语言和框架TypeScript,然后取消选中“启用TypeScript编译器”选项:

WebStorm首选项中的TypeScript编译器

After that, delete the TypeScript compiler output files: 之后,删除TypeScript编译器输出文件:

WebStorm TypeScript编译器输出

Now your application should work again. 现在您的应用程序应该再次运行 Happy coding! 快乐的编码!

your xyz.js file code is 你的xyz.js文件代码是

  console.log("This is test panel ....");
  new Mongo.Collection('players');           <<-------remove This line 
    PlayersList = new Mongo.Collection('players');

remove 去掉

new Mongo.Collection('players');

I had this error because I had new'd the same mongo collection into two different variables. 我有这个错误,因为我将同一个mongo集合新增为两个不同的变量。

eg 例如

CrowdEstimates = new Mongo.Collection('crowdEstimates');
CrowdEstimateAggregations = new Mongo.Collection('crowdEstimates');

Cut and paste and distraction.... 剪切和粘贴和分心....

我认为你在app/collections/collection.js方法名称相同

I encountered the same error message, it happened after I reorganized the folder structure of my application. 我遇到了相同的错误消息,它发生在我重新组织我的应用程序的文件夹结构后。 I had a collection Javascript named drivers.js in a folder named both and I had another Javascript file with the same name (and code) in both\\collections\\drivers.js . 我在一个名为both的文件夹中有一个名为drivers.js的集合Javascript,我在both\\collections\\drivers.js有另一个具有相同名称(和代码)的Javascript文件。

So the error message is more-or-less correct. 因此错误消息或多或少是正确的。 Just weird looking, at least on my system. 看起来很奇怪,至少在我的系统上。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM