Setting up Habitica Locally

We are currently porting this article from our GitHub site. Please excuse any errors or omissions while we're working on it.

You might wish to set up HabitRPG locally (so that it runs on your own computer) if you are a developer and want to test changes you have made to the code.

Unix
Windows users should skip this section and read the one below with Windows-specific steps.

Before starting make sure to have MongoDB, NodeJS (and npm) and Git installed and set up.
 * 1) Fork the repository on your computer.
 * 2) Checkout the develop branch where all the development happens: git checkout -b develop origin/develop
 * 3) Install grunt-cli npm package globally (on some systems you may need to add sudo in front of this command): npm install -g grunt-cli bower
 * 4) Install the npm and bower packages: npm install
 * 5) Create a config file from the example one: cp config.json.example config.json
 * 6) Edit config.json with your values for ADMIN_EMAIL, SMTP_USER, SMTP_PASS and SMTP_SERVICE

Set up MongoDB

 * 1) Download the latest production release of MongoDB
 * 2) Extract the zip file to the desired application directory. Example: c:\apps\mongodb-win32-x86_64-2.4.6
 * 3) Rename the folder from mongodb-win32-x86_64-2.4.6 to mongodb
 * 4) Create a data\db directory under the application directory. Example: c:\apps\mongodb\data\db
 * 5) Start up MongoDB using this command: c:\apps\mongodb\bin\mongod.exe --dbpath c:\apps\mongodb\data

If MongoDB starts up successfully, you should see the following at the end of the logs: Sun Sep 01 18:10:21.233 [initandlisten] waiting for connections on port 27017 Sun Sep 01 18:10:21.233 [websvr] admin web console waiting for connections on port 28017

Install the other requirements

 * 1) Download and run the latest Node.js msi installation file
 * 2) Install Git
 * 3) Fork the repository on your computer.
 * 4) Checkout the develop branch where all the development happens: git checkout -b develop origin/develop
 * 5) Install the npm packages: npm install You might receive the following error during the 'npm install' command: habitrpg@0.0.0-152 postinstall C:\Users\022498\Projects\habitrpg ./node_modules/bower/bin/bower install -f '.' is not recognized as an internal or external command, operable program or batch file. npm ERR! weird error 1 npm ERR! not ok code 0 Ignore this error and proceed with the following:
 * 6) Install grunt-cli and bower npm packages globally: npm install -g grunt-cli bower
 * 7) Install the bower packages: bower install -f
 * 8) Create a config file from the example one: cp config.json.example config.json
 * 9) Edit config.json with your values for ADMIN_EMAIL, SMTP_USER, SMTP_PASS and SMTP_SERVICE

Run HabitRPG
HabitRPG uses Grunt as its build tool.


 * 1) From the command line of your habitrpg git directory, start the Mongoose database with: mongod
 * 2) On another Terminal tab, EITHER:
 * 3) Compile the Stylus files and start a web server with: grunt run:dev OR:
 * 4) Type: npm start which initiates 'grunt run:dev'
 * 5) Open a browser to http://localhost:3000 to test the application!

Note: 'grunt run:dev' uses Nodemon and grunt-contrib-watch to automatically restart the server and re-compile the files when a change is detected.

See Troubleshooting

Updating
As other authors make changes to HabitRPG, your local copy will fall behind. To bring it up to speed, do the following: git pull origin develop npm update bower update

Tips

 * Git
 * MongoDB
 * Angular/Node/Jade Tips &amp; Best Practices
 * Other
 * Installation troubleshooting

Technologies discussion
Angular, Express, Mongoose. Awesome, tried technologies. Read up on them. Stylus, Jade - big debate. Jade. We need a server-side templating language so we can inject variables (res.locals from Express). Jade is great because the "significant whitespace" paradigm protects you from HTML errors such as missing or mal-matched close tags, which has been a pretty common error from multiple contribs on Habit. However, it's not very HTML-y, and makes people mad. We'll re-visit this conversation after the rewrite is done. Stylus. We're either staying here or moving to LESS, but vanilla CSS isn't cutting it for our app.