Confessions of a hobbyist


Hello community,

I have been using meteor since v0.6 or so.

In all these years, Meteor helped me to both find side jobs (aside of studying physics) and bring to life my own ideas. Some of the apps I’ve made have had a reasonable amount of success. In all these years I’ve stayed with meteor since it always changed at a fine, slow speed for me.

But now all my apps are still on version 1.6. The reason is that I cannot have any global variables in later versions. And that bugs me. For instance: I’ve always used the browser console very extensively during development, but now I cannot even access my collections anymore through the console… I do understand that it makes sense to encourage coding practice which aligns more with the rest of the js community. But that does not mean that one has to remove the ability to have global variables.


@mytamhuyet Hey there, globals work just fine. At any point in your clientside code, you can easily write window.someVariable = "Foo" and now it is global.

Also, anything outside of an imports folder loads the old way, as globals. It works just like old Meteor.

If you read the 3rd paragraph of the following section in the docs, you will see that it mentions old-style globals still work just fine if you want to do things that way:

Hope that helps!


Welcome mytamhuyet!

I think there’s some misunderstanding. Nothing about newer Meteor versions prevents having global variables.

I just tested out declaring variables in file scope without var, ie:

// client/main.js
TestGlobal = { name: 'test' };

And it was available on the console.

Happy to help debug why some variable or module isn’t global if you want :slight_smile:


If you want to write globals that are used in shared (client and server) it works also fine using the explicit global statement:

global.Myvar = { }


There is chrome extension which can help you to manage minimongo:


You can still test your collection in console.log quite easily by exporting your variables and Collections.

In file foo.js:

export const collection = new Mongo.Collection('some-name');

And then in console.log you simply do: const { collection } = require('./foo.js');

The same applies for all other variables and you have no more need for creating anything globally anymore.

Hope this helps.