首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Meteor ReferenceError:升级到1.3后未定义集合

Meteor ReferenceError:升级到1.3后未定义集合
EN

Stack Overflow用户
提问于 2016-01-30 11:34:18
回答 2查看 1.3K关注 0票数 1

在将Meteor版本从1.2升级到1.3之后,我得到了以下错误:

代码语言:javascript
复制
=> Started proxy.
=> Started MongoDB.
W20160130-14:27:48.841(3)? (STDERR)
W20160130-14:27:48.841(3)? (STDERR) C:\Users\Vladimir\AppData\Local\.meteor\pack
ages\meteor-tool\1.1.12-modules.5\mt-os.windows.x86_32\dev_bundle\server-lib\nod
e_modules\fibers\future.js:245
W20160130-14:27:48.841(3)? (STDERR)
throw(ex);
W20160130-14:27:48.841(3)? (STDERR)
      ^
W20160130-14:27:48.841(3)? (STDERR) ReferenceError: Games is not defined
W20160130-14:27:48.841(3)? (STDERR)     at meteorInstall.lib.collections.js (lib
/collections.js:1:1)
W20160130-14:27:48.841(3)? (STDERR)     at fileEvaluate (packages/modules-runtim
e/.npm/package/node_modules/install/install.js:183:1)
W20160130-14:27:48.841(3)? (STDERR)     at require (packages/modules-runtime/.np
m/package/node_modules/install/install.js:75:1)
W20160130-14:27:48.841(3)? (STDERR)     at C:\code\steambot\.meteor\local\build\
programs\server\app\app.js:404:1
W20160130-14:27:48.841(3)? (STDERR)     at C:\code\steambot\.meteor\local\build\
programs\server\boot.js:242:10
W20160130-14:27:48.841(3)? (STDERR)     at Array.forEach (native)
W20160130-14:27:48.841(3)? (STDERR)     at Function._.each._.forEach (C:\Users\V
ladimir\AppData\Local\.meteor\packages\meteor-tool\1.1.12-modules.5\mt-os.window
s.x86_32\dev_bundle\server-lib\node_modules\underscore\underscore.js:79:11)
W20160130-14:27:48.841(3)? (STDERR)     at C:\code\steambot\.meteor\local\build\
programs\server\boot.js:137:5
=> Exited with code: 8

我的档案结构:

代码语言:javascript
复制
-.meteor
-client
-server
-public
-lib (collections.js here)

collections.js:

代码语言:javascript
复制
Games = new Mongo.Collection('games');

在升级到1.3之前,一切都很好。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2016-01-30 11:48:15

而不是

代码语言:javascript
复制
Games = new Mongo.Collection('games');

代码语言:javascript
复制
global.Games = new Mongo.Collection('games');

因为

在beta 5中,全球都有问题。

更多信息:https://github.com/meteor/meteor/issues/5788#issuecomment-175927524

票数 2
EN

Stack Overflow用户

发布于 2016-05-13 17:44:17

在Meteor1.3中,推荐的方法是使用import,而不是将所有东西都迁移到全局。

代码语言:javascript
复制
// collections.js
export const Games = new Mongo.Collection('games');

然后

代码语言:javascript
复制
// any_other_file.js
import { Games } from '../lib/collections'
票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/35101258

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档