Meteor back-wards compatible, imports

Hello, I learned meteor through the University of London specializations courses. It was with an older version, not using imports. I know that there is a great value to the import statements but I wanted to try and see if the tutorial works without it.

I have the following html:

	<div class="container">
			<h1>Todo List</h1>

			<form class="new-task">
				<input type="text" name="text" placeholder="Type to add new tasks" />

			{{#each tasks}} {{> task}} {{/each}}


<template name="task">

Then in the server folder (main.js)

var Tasks = new Mongo.Collection('tasks');

and finally in the client folder (main.js)

	tasks() {
		return Tasks.find({});
	'submit .new-task' (event) {
		// Prevent default browser form submit

		// Get value from form element
		const target =;
		const text = target.text.value;

		// Insert a task into the collection
			createdAt: new Date(), // current time

		// Clear form
		target.text.value = '';

However, when I run this. I get the error that Tasks is not defined.

Why am I getting this error, shouldn’t it communiciate with the server.js file and know that Tasks has been defined as a database? Even if I put in an import statement (which I am currently trying to avoid just to see if it can be done) it doesn’t work.

How can I fix this?

Put the Tasks collection definition in a common folder like /lib and don’t put var in front (or Tasks will just be defined for that particular file).

i.e. In





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

That will ensure Tasks is a global in all parts of the app.

Hey, thanks for the response.

I removed the var declaration and moved the statement into a collections.js file in the lib folder.

However, it then gave me the error that tasks is already defined in Mongo.

In order for it to work, I had to rename it in the collections file to pasks with a p.

Why did this happen, is tasks a protected word?

You have defined the collection already somewhere else in your app.

Search for “Collection(‘tasks’)” in your project folder’s files and you’ll find where (probably in the /server/main.js, since you had it there before following @babrahams advice )

I had removed it but perhaps it didn’t save.

I reset the server and now it works with ‘tasks’