Habilelabs-Logo
Blog

Getting started with meteor packages (Install, Use and Build)

August 14th, 2016 . 3 minutes read
Blog featured image

Getting started with meteor packages (Install, Use and Build):

What are meteor packages?

Let’s say you’re making your on a functionality and you realize that some of your functionality could be used in almost any app. In this case, we need to make you independent of your application and make it shareable.

In this case, you need to create a meteor package. This can be installed in any application and it will be working without no extra effort.

This tutorial will get you started on your first meteor package.

Create your first Meteor package:

Getting started with meteor packages, create meteor package and publish. first meteor package. how to create meteor package. tutorial meteor package

atmospherejs is a central repository of meteor package, We create, download and publish packages from here. before getting started please create your account on
atmospherejs.

Let’s start by creating a new meteor project.

Now we will create an internal package to this application. A Meteor project can have external and internal packages. External packages are directly user from meteor package manager atmospherejs.
Meteor expects ‘packages’ folder for internal packages.

Create a packages folder in the project folder.

In here we store all our custom made packages. Before we create one, we have to remember that the name of our package needs to be in a particular format: “username:packagename”, where username is your Meteor Developer username. If you still have created account on atmospherejs then please create an account. My user name is ‘morwal89’. So after this in this tutorial, I will be using this name. you can use your user name.

Now we will create one sample package.

This will create a folder ‘simple’ and will create some files inside this folder. It creates packages.js, simple.js, simple-test.js.
We will try to create a simple template.

Add simple-template.html

One Simple TEMPLATE

Create entry of this newly created file inside package.js. As this file is will load on the client we will use client tag.

Now we will need to add this new package to our application. Even this is internal package still we need to create dependency. without this, you can get errors like “lookup.js:189 Uncaught Error: No such template: simpleTemplate”
Run command following command in application root folder to add this.

We are ready. Now will reference this template in our application.

Edit the main.html inside client folder.

Welcome to Meteor!

{{> simpleTemplate}}

Run Meteor project.

You will on screen One Simple TEMPLATE on screen.

Publish your meteor packages:

Now we will publish this package on atmosphere.

You will need to login to meteor shell using the command line. Go to simple package root folder and log in on Meteor.
To login run

This will ask you username and passwords. After login completed you are ready to publish your first package.
run following command

Congrats your first package is published. Login to atmospherejs to see your first published package.

Still having a problem in this process? Let me know in comments sections. I uploaded the full source code for a tutorial on GitHub. Download this from Here . We are best wed development service provider

Hope you enjoy this post, so don’t forget to share with friends.

[/et_pb_text][/et_pb_column][/et_pb_row][/et_pb_section]

Author: morwal89
Share: