How to deploy MEAN app on Heroku
MEAN stands for MongoDB , ExpressJS, AngularJS, NodeJs. MEAN is an opinionated fullstack javascript framework - which simplifies and accelerates web application development.
Very first you have to setup local environment with MongoDB and NodeJS. Please check and install NodeJS from www.nodejs.org.
Install MongoDB on your local machine. Due to install MongoDB and NodeJS you’ll need to install HomeBrew first.
Install homebrew
Install Node.js by brew
Now this is the time to install MongoDB To install the MongoDB binaries, issue the following command in a system shell:
To build MongoDB from the source files and include SSL support, issue the following from a system shell:
To install the latest development release for use in testing and development, issue the following command in a system shell:
Now we’re ready to install MEAN app on your local machine.
To install MEAN app scaffold
Now you can initiliaze your MEAN app
MEAN Package install & uninstall
Available packages - mean-admin - tokens - translate - ga (Google Analytics) - upload - socket - gmap - comments - crop
usage example
Uninstall package
Delete package
NOTE: Run Grunt service after your changes to compile your script.
#Setup Heroku Account
In order to work with Heroku, you also need to download Heroku’s toolbelt (https://toolbelt.heroku.com) which will give you the needed command line tools to communicate with Heroku’s backend. Right after registering in Heroku and installing it’s toolbelt, run the following command and add your SSH key, to identify yourself with Heroku:
You’ll need your email address and password for Heroku. Before you push your repo, you need to add public key into your heroku.
Generate the RSA key first by following
Add your key to heroku
Read more about SSH key https://devcenter.heroku.com/articles/keys
Before you go further let’s setup your database on Heroku.
Login to your Heroku dashboard goto Add-ons tab and find MongoHQ under Data Stores. Select free plan and add to your package. Now go to your apps. Select MongoHQ from your app list.
Goto Admin tab (on the left side) and select Users tab on top of the panel. From here you can setup your MongoDM access by adding a user.
Copy your Mongo URI
Now you’re ready to push your code into your Heroku
#Setup your MEAN App config
Very first you have to setup your MongoDB on your config to run your scaffold app.
go to /yourApp/config/env/development.js
find mongodb:localhost
replace with your MongoURI
#Prepare to push Heroku
Now this is a time to push it
Now you can see your project http://yourApp.herokuapp.com
Enjoy playing around
Here is the live example of MEAN app deployed in Heroku http://ariunbolor.herokuapp.com