Meteor JS main.js only accepts 'imports' directory instead of 'client'

I am new to Meteor and am trying out the basic todo app but running into some difficulties. The tutorial mentions adding files to 'imports', but this directory was not created when we ran meteor create, nor were we instructed to make such a directory. In any case, main.js main.html, and main.css were all stored in the client directory. When I created a subdirectory called api and added tasks.js and tried to import it in the server side main.js, the app crashed because it could not find the file.


import { Meteor } from 'meteor/meteor';
import '../client/api/tasks.js';

Meteor.startup(() => {
  // code to run on server at startup

When I renamed the director 'client' to 'imports', the app magically no longer crashed, but suddenly, nothing was being rendered on the client side. Does the server side main.js look for 'imports' as if it were a keyword? Why can't it find the file in 'client?'


import { Mongo } from 'meteor/mongo';

export const Tasks = new Mongo.Collection('tasks');


By default, a Meteor app loads all JS files in the project directory, unless it's in some specially named directory. The imports directory is one of these special directories - files in it are only loaded if they are explicitly imported by other files. The client directory is special too in that its contents are only loaded by client code, and never by server code. You don't, however, need to import files from the client folder, as they are included by Meteor automatically.

The current recommendation is to include most of your app code in the ìmports directory, and only import it when you need it. The default meteor create command does not create this directory for you, so you should just create it yourself. If the tutorial you read does not tell you to create one, then it should. Using the ES6 import - export system helps structuring your code and keeping track of project dependencies better.

For more information about Meteor directory structure, I recommend reading the relevant chapter in the Meteor guide. There's also a list of special directories.

Need Your Help

Display image before page load

ios timer uiimageview

I have four tabs in an ios application. I want to display image preview from view load. How can I fix it?

in QTP, how to check whether a dialog is already open?

vbscript qtp

I have been using the following code to check whether a dialog is already open