2016-05-14 46 views
0

我是流星的新手,尝试使用流星与React并按照教程https://www.meteor.com/tutorials/react/collections。 但是我坚持将服务器api/tasks.js文件导入到客户端App.jsx中。我尝试了所有可能的相对路径,但它不起作用。我在浏览器中不断收到错误消息。流星客户端反应app.jsx无法导入服务器api/tasks.js模块

install.js:78 Uncaught Error: Cannot find module './../../../server/imports/api/tasks.js' 

以下是我的代码文件夹结构供参考。 enter image description here

以下是API/tasks.js代码参考

import { Mongo } from 'meteor/mongo'; 
export const Tasks = new Mongo.Collection('tasks'); 

以下是我的流星命令,它没有与此相关的模块的任何错误。

bash-3.2$ meteor 
[[[[[ ~/Dilip/Projects/FindYourLove/SourceCode/FindYourPartner ]]]]] 

=> Started proxy.        
=> Started MongoDB.       
=> Started your app.       

=> App running at: http://localhost:3000/ 

请帮忙。

回答

2

阅读流星文件夹结构指南后,我意识到客户端无法访问“服务器”文件夹内的模块。这是我得到这个错误的原因。根据流星指南,任何常见模块需要放在“客户”和“服务器”平行的“导入”文件夹内。做这个改变后,它的工作正常。 http://guide.meteor.com/structure.html这是流星指南。以下是新文件夹结构的截图。 enter image description here