流星会话未定义 [英] Meteor Session is not defined
问题描述
当我运行流星项目时,发生了此问题:
when I run my meteor project, this problem occurred:
ReferenceError: Session is not defined
at app/_components/talk/views/friends_list.coffee.js:1:16
at /home/xyz/web/edp/.meteor/local/build/server/server.js:298:12
at Array.forEach (native)
at Function._.each._.forEach (/home/xyz/.meteorite/meteors/meteor/
meteor/9bb2b5447e845c4f483df5e9b42a2c1de5ab909b/
dev_bundle/lib/node_modules/underscore/underscore.js:78:11)
这是我的目录结构(我已经更改了文件名):
here is my directory structure (I have changed the name of the files):
├── _components
│ ├── project_form
│ │ └── client
│ │ ├── lib
│ │ │ └── ...
│ │ ├── project_info
│ │ │ ├── x1.coffee
│ │ │ ├── x2.html
│ │ │ ├── x3.coffee
│ │ │ └── x4.html
│ │ └── views
│ │ ├── x5.coffee
│ │ └── x6.html
│ ├── README.md
│ └── talk
│ └── client
│ ├── x7.coffee
│ ├── x8.html
│ ├── x9.coffee
│ ├── x10.html
│ ├── x11.coffee
│ ├── x12.html
│ ├── x13.coffee
│ ├── x14.html
│ └── x15.less
如果我将目录结构更改为以下内容, 流星运行正常.我真的不知道为什么,怎么会这样呢? 我认为文件加载顺序可能会有所不同. 但我无法弄清楚.
If I change the directory structure to the following, meteor runs correctly.I really don't know why, how could it happened? I think the file loading order may make a difference to it. But I can't figure it out.
├── _components
│ ├── project_form
│ │ └── client
│ │ ├── lib
│ │ │ └── ...
│ │ ├── project_info
│ │ │ ├── x1.coffee
│ │ │ ├── x2.html
│ │ │ ├── x3.coffee
│ │ │ └── x4.html
│ │ └── views
│ │ ├── x5.coffee
│ │ └── x6.html
│ ├── README.md
│ └── talk
│ └── client
│ └── views
│ ├── x7.coffee
│ ├── x8.html
│ ├── x9.coffee
│ ├── x10.html
│ ├── x11.coffee
│ ├── x12.html
│ ├── x13.coffee
│ ├── x14.html
│ └── x15.less
推荐答案
这可能是因为Session
仅在客户端上起作用,而在app/_components/talk/views/friends_list.coffee.js
上也可以在服务器上运行.
This might be happening because Session
only works on the client and at app/_components/talk/views/friends_list.coffee.js
it would also be run on the server.
您可能希望将所有视图/客户端内容移动到/client
目录中或将其放置在以下位置:
You might want to move all your views/client side stuff into the /client
directory or place it in:
if(Meteor.isClient) {
}
这篇关于流星会话未定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!