Adding basic packages
Packages in Meteor are libraries that can be added to our projects. The nice thing about Meteor packages is that they are self-contained units, which run out of the box. They mostly add either some templating functionality or provide extra objects in the global namespace of our project.
Packages can also add features to Meteor's build process such as the stylus
package, which lets us write our app's style files with the stylus
preprocessor syntax.
For our blog, we will need two packages at first:
less
: This is a Meteor core package and will compile our style files on the fly to CSS
jeeeyul:moment-with-langs
: This is a third-party library for date parsing and formatting
Adding a core package
To add the
less
package, we can simply open the terminal, go to our projects folder, and enter the following command:
$ meteor add less
Now, we are able to use any *.less
files in our project, and Meteor will automatically compile them in its build process for us.
Adding a third-party package
To add a third-party package, we can simply search for packages on either https://atmospherejs.com, which is the frontend for Meteors packaging system, or use the command-line tool, $ meteor search <package name>
.
For our blog, we will need the jeeeyul:moment-with-langs
package that allows us later to simply manipulate and format dates.
Packages are namespaced with the authors name followed by a colon.
To add the moment
package, we simply enter the following command:
$ meteor add jeeeyul:moment-with-langs
After the process is done, and we restarted our app using $ meteor
, we will have the moment
object available in our app global namespace and we can make use of it in the upcoming chapters.
Should we ever want to add only specific version of a package, we can use the following command:
$ meteor add jeeeyul:moment-with-langs@=2.8.2
If you want a version in the 1.0.0 (but not the 2.0.0) range use the following command:
$ meteor add jeeeyul:moment-with-langs@1.0.0
To update only packages we can simply run the following command:
$ meteor update –-packages-only
Additionally, we can update only a specific package using the following command:
$ meteor update jeeeyul:moment-with-langs
That's it! Now we are fully ready to start creating our first templates. You can jump right into the next chapter, but make sure you come back to read on, as we will now talk about Meteor's build process in more detail.