Meteor is quite an easy Javascript framework to pick up and I have been fascinated getting back to where I left off a couple of years ago.
There are quite a few things that you could do in the first week itself, and could even target to complete real-world projects.
However, be aware - MeteorJS is a ghost town of sorts.
The usage has declined rapidly over the past three years, and most of the content that you will find is outdated. Students of the framework will find older tutorials that do not quite work. For all my hubris, I still ended up spending time on debugging silly problems that should not have existed in the first place.
One of the popular tutorials of MeteorJS from LevelupTuts is on YouTube - Meteor for Everyone.
The tutorial can get you started quickly, but the framework itself does not quite recommend writing in the “older” way anymore. You’ve to make small amends to follow along if you choose to use the tutorial anyway - below paragraphs should give you a good idea on the changes.
Folder Structure
Create the following structure that can be beneficial for later.
- client (accessible only for the client - created automatically )
- server (accessible only for the server)
- lib (common for both)
If you follow a specific structure (which is highly recommended in Meteor), you may not do the following each time -
|
|
You may also see a reason to remove the main.js file references in package.json, or change references to point to your own files. This will avoid errors that tell you about required main.js files in client and server.
Create Collections
The tutorial talks about creating a collection called ‘Resolutions’. The code outlined in the tutorial will not work unless you import ‘Resolutions’ on the server side.
A file ‘main.js’ gets created automatically in the server folder when you create a new project through meteor create
Include the code below in [server folder]
> main.js
.
|
|
Instead of creating a collection within a client-specific JS file (as outlined in the tutorial), create a new file called ‘collections.js’ under the ‘lib’ directory (you did create the folder structure outlined above?)
In collections.js, include the following code -
|
|
Lastly, in the ‘js’ file for the client (e.g., ‘main.js’ in client folder), include -
|
|
There some funny ways to do the above in the ‘new way’, but let’s keep things simple for all learners.