Search code examples
meteormeteor-react

meteor client react app.jsx is not able to import server api/tasks.js module


I am new to meteor and trying to use the meteor with React and was following the tutorial https://www.meteor.com/tutorials/react/collections. However I stuck to import the server api/tasks.js file into client side App.jsx. I tried all the possible relative path however it didn't work. I keep getting following error in the browser.

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

Following is my folder structure in code for reference. enter image description here

Following is api/tasks.js code for reference

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

Following is my meteor command, it doesn't have any error related to this module.

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

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

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

Please help.


Solution

  • After reading meteor folder structure guide, I realized that client can't access the modules inside "server" folder. This was the reason I was getting this error. As per meteor guide, any common module needs to be put inside "imports" folder parallel to "client" and "server". After making this change its working fine. http://guide.meteor.com/structure.html this is meteor guide. Following is screenshot for new folder structure. enter image description here