Can anyone give me a quick rundown on how to properly import modules on Meteor?


Let’s say I install a random Meteor package to use on my React-Meteor project.

How do I know the path of the module? For example, an arbitrary package called MyPackage…

import myPackage from "xxxxx";

How do I know what to type in place of “xxxxx”? When importing react, I simply just write “react” and when import Meteor, I have to type in “meteor/meteor”.

I just don’t see any consistency here and would like to know how to know the correct way to import modules, no matter which one I download.


For Meteor packages the rule is 'meteor/creator:package-name'. For MDG packages (like reactive-var), the creator: part is omitted, so 'meteor/reactive-var'.

Basically, it’s exactly what you see in atmosphere with meteor/ at the front.


Thanks for this Rob.
Something I was struggling with just today.
I was getting errors that said moment is undefined.
So I need to: import meteor/momentjs:moment yes?
(I have already added the package via meteor add momentjs:moment)


TBH I’d recommend removing moment:momentjs and using the npm moment package directly.

meteor npm install moment --save

and then import it where you need it with import moment from 'moment';

But you could certainly try sticking with the moment:momentjs package and see if import { moment } from 'meteor/moment:momentjs'; works.


Thanks again Rob.
I’ll give it a go when I’m back at work tomorrow.


Hey Rob, thank you for the helpful reply.

I see below you said you would prefer NPM packages directly over Atmosphere? Do you recommend that for everything or just select cases?


“Everything” is not currently possible, nor is it always desirable. Generally speaking though, in Meteor 1.3+, I would go with native npm modules. There is an argument for stability with a wrapped atmosphere package, but all too frequently that’s just a euphemism for “abandoned”. I still make exceptions for core Meteor packages (which is pretty obvious, I guess!) and a number of useful atmosphere packages which offer genuinely useful functionality (like astronomy, for example).