The first step to contributing code to Habitica's website is setting up a local instance of the website to test your changes. This page contains instructions for how to do this in all major operating systems. Read each section in order, ensuring that every instruction is followed before moving on to the next. It is important to also read Guidance for Blacksmiths. This page is not relevant for contributing to development for the mobile apps.

If you are upgrading a local install that was made before October 2016, it is recommended that you delete your local install and go through the full installation process described on this page.

Choose Your Platform Edit

Most of the sections on this page must be followed regardless of which operating system you are using. However, when you come to the "Instructions by Operating System" section, you'll find it contains these sub-sections:

  • Windows - for installing Habitica directly onto a Windows PC
  • Mac OS / Linux / Unix - for installing Habitica directly onto a Mac or *nix computer (recommended if your PC runs one of those platforms)
  • Vagrant - for installing Habitica on a Ubuntu virtual machine using Vagrant, which can be run on Windows, Mac OS, and *nix (recommended for Windows if you have trouble creating an install directly on Windows, but not recommended otherwise)
  • Docker - for running Habitica in a Docker container
  • Uberspace - for running Habitica using Uberspace

You need to follow only one of those sub-sections - whichever one is appropriate for how you want to run Habitica locally. You do not need to install the Vagrant, Docker, or Uberspace programs if you are not using those methods.

Prepare for Troubleshooting Edit

A local install does not always go smoothly but we will be happy to help you! Habitica uses a lot of software and we understand that it can be complicated to install it all until you are used to it. Please follow all the steps in this section before you experience errors so that, if necessary, you can ask for help easily and we can assess your problem rapidly.

As you are installing Habitica:

  • Record every command that you type and the full output of every command - save all the commands and outputs into text file(s) in case we need to see them later.
  • Carefully read all output messages to look for errors.
    • If you see an error, do not proceed further until the error has been resolved because later steps are likely to not work correctly.
    • However, you can ignore:
      • deprecation warnings (npm WARN deprecated ...)
      • optional dependency failure warnings (npm WARN optional Skipping failed optional dependency...)
      • npm WARN notsup Not compatible with your operating system or architecture: fsevents@1.0.12
  • If you need to deviate from any instructions anywhere on this page, record what you have done that is different and why. If you later need assistance, it is vital that the people helping you know about those differences, otherwise time can be spent on advice that isn't relevant to you.

If you need help with fixing any errors, upload all of the information you have gathered so far onto a site such as GitHub Gist, then either post in the Aspiring Blacksmiths (Habitica Coders) guild or log an issue in GitHub and tell us all of this:

  • which operating system your PC/laptop is running
  • which of the following methods you are using:
    • installing Habitica directly onto your PC/laptop
    • installing Habitica using the Vagrant or Docker or Uberspace instructions on this page
    • installing Habitica onto some other virtual machine - include which operating system it is running
  • any deviations you needed to make from the standard instructions
  • any other information the instructions on this page asked you to record
  • links to your uploaded file(s)
  • what problem you're experiencing

Install Git Edit

Create a GitHub account if you don't already have one.

Install git on your machine (installation instructions available here).

Windows Line Endings Edit

This section is only relevant if you are using a Windows PC (either with or without Vagrant).

*nix operating systems (Linux and Mac OS X) handle line endings differently than Windows. *nix systems use the line feed (LF) character \n, while Windows uses a combination of a carriage return and line feed, \r\n (CRLF). Since Habitica developers use a variety of operating systems, to allow for maximum compatibility, Git on Windows must be set up to ensure that only LF line endings are committed to the repo.

Windows Git Setup

Configuring the line ending conversions

How you set this up depends on whether you will be doing all your Habitica development work directly in Windows or you will be installing a Unix Vagrant virtual machine on your Windows PC and using the Vagrant machine for all development. The appropriate setting can be chosen when installing Git (see the screenshot but read on before you chose an option) or afterwards using a simple command-line tool.

If you are intending to install Vagrant as described later in this page and will be doing all your Habitica development in the Vagrant machine, then when presented with the "Configuring the line ending conversions" window, select "Checkout as-is, commit Unix-style line endings". Alternatively, configure that setting from the command line by running
git config --global core.autocrlf input

If you will not be using a virtual machine and instead will be doing all your development work directly in Windows, then select "Checkout Windows-style, commit Unix-style line endings", or configure it by running
git config --global core.autocrlf true

If you chose one setting now and later decide to change how you do your development work, you can use the appropriate git config --global core.autocrlf ... command to change the setting.

For further information on line endings and whitespace in Git, see the "Formatting and Whitespace" section in the Pro Git book.

If you don't want to set the core.autocrlf setting globally, see Dealing with line endings > Per-repository settings to learn how to set it for individual repositories. This will only be relevant to you if you are already using Git for other projects or will be using it for others in future.

Fork and Clone Habitica Edit

Acquire a copy of Habitica's codebase. There are multiple methods of doing this; the following is the simplest method, and is based on GitHub's Fork A Repo article.

  1. Fork Habitica's repository by going to and clicking on the "Fork" button. This creates a copy of Habitica's repository in your own GitHub account.
  2. On your machine, open a command prompt or terminal window. Change to the directory that you want to Habitica's codebase to be copied under.
  3. Clone your copy of Habitica's repository with the command below (replace "YourUsername" with your GitHub username). This will copy Habitica's code onto your machine, placing the repository into a new "habitica" directory under your current directory.
    git clone
  4. Change into the "habitica" directory that was created by the above step:
    cd habitica
    Remain in that directory for all future steps on this page, unless advised otherwise.
  5. Configure Git to sync your fork with Habitica's repository.
    git remote add upstream
  6. Verify that everything is set up properly by typing git remote -v which should produce output the same as the following but with your GitHub username in place:
  origin (fetch)
  origin (push)
  upstream (fetch)
  upstream (push)

After you have cloned Habitica's repository, you will be in the develop branch by default. This is the correct branch to be in when installing Habitica locally. You do not need to change to any other branches but if you do for any reason, you must switch back to the develop branch with git checkout develop before proceeding further with the installation. You can check which branch you are on with git branch (the branch with a star next to it is the branch you are currently on).

Initial Habitica ConfigurationEdit

Note for Windows: All cp commands on this page should be replaced with copy

  1. Create the config.json configuration file by copying (not renaming) the example one:
    cp config.json.example config.json
  2. Normally you do not need to edit config.json, but if you are aware of any reason to, you can do it now. It can also be edited at any later time if needed.
  3. There is no reason to change the values for ADMIN_EMAIL, SMTP_USER, SMTP_PASS and SMTP_SERVICE. They are used to configure the sending of emails and the email features will not work in development, even with those values supplied.

Node and npm Versions Edit

The instructions below include steps for installing Node and npm. When you reach those steps, be aware that the correct versions to use are Node 6 and npm 4. You will experience errors if you use any other versions. The instructions will tell you how to find which versions you have installed.

The version numbers are not necessarily listed below to avoid the instructions becoming inaccurate if we forget to update one section when the version numbers change. Please refer to this section whenever you need to know the correct versions to use.

If you need to use different versions on your development machine for work not related to Habitica, you can use nvm to manage the versions.

Instructions by Operating System Edit

This section contains the following sub-sections and you need to follow only one of them (ignore the others):


  1. Install the Visual C++ 2015 build tools. This step might not be necessary but recent contributors using Windows installs have indicated that it might be needed for some of Habitica's dependencies to be installed (e.g., bcrypt). If you have feedback about this, please post to the Aspiring Blacksmith's guild.
  2. Follow the MongoDB's official instructions to install MongoDB Community Edition on Windows.
  3. Close any applications or file explorer windows that might be reading your local copy of the repository. The installation steps might fail if any of the files are locked by any Windows processes. For antivirus software, make an exception in its settings so that it won't scan the repository until the install is complete. For reference, see from this GitHub comment to the end of the issue.
  4. Download and run the latest Node.js msi installation file. Refer to the Node and npm Versions section above for the correct version of node to install.
  5. Launch a command window as Administrator and in that window:
    1. Check that you installed node successfully and that it is the correct version (if it is not, redo the node installation using the correct download):
      node -v
    2. Installing NodeJS also installs npm. Check that that has been done and that the version is correct:
      npm -v
      • If the version of npm is not the one listed in the Node and npm Versions section above, install the correct version. For example, if npm 4 needs to be installed:
        npm install -g npm@4
    3. Install some npm packages globally:
      npm install -g gulp grunt-cli bower mocha
    4. Install some dependencies necessary for the bcrypt package:
      npm install -g node-gyp
      npm install --global --production windows-build-tools
      If this doesn't work you may have to install some extra dependencies listed here:
  6. Close the command window and open a new one without using Administrator permissions so that all further instructions are run as a non-Administrator user.
  7. Create a directory by executing mkdir website\build
    If it gives you an error that the directory already exists, ignore the error and proceed with the next step
  8. Install the Habitica-specific npm packages:
    npm install
    • If you see any errors at this point or if any subsequent steps on this page show you errors about missing modules or files, the npm install command might not have run correctly. Please report that in the Aspiring Blacksmiths (Habitica Coders) guild, even if you are able to resolve the problem yourself, because we have recently made changes to this process and would very much like to know about problems with it.
  9. Follow the instructions in the Run Habitica section below.

Mac OS or Linux or Unix Edit

Set Up a Swap File on Mac OS / Linux / Unix Edit

It is likely that you will need a swap file of at least 4 GB, otherwise you will have persistent errors when running the "npm install" and "npm start" commands (for examples of errors, see this GitHub issue). Your computer might already have a swap file. Find appropriate instructions on the internet for viewing or creating a swap file for your platform.

If you have a swap file but still cannot run the "npm install" and "npm start" commands successfully, try increasing the size of the swap file.

Record the size of your swap file now. If you later need to ask for help, include it in the troubleshooting information if you give us.

For the remainder of these instructions, you should not be logged in as the root user. Log in with the user account that you will be using when you are developing for Habitica. The instructions will specify sudo when root permissions are needed and using root permissions at other times will cause problems.

Install NodeJS and npm for Mac OS / Linux / Unix Edit

  1. Check that inappropriate versions of NodeJS and npm are not installed:
    node --version; nodejs --version
    • Refer to the Node and npm Versions section above for the versions that are needed.
    • If that command shows that node/nodejs is not installed, proceed to the next step.
    • If it shows that you have a version of node/nodejs that is less than the required version, uninstall it. On Ubuntu, the commands to uninstall it are:
      sudo apt-get purge nodejs -y; sudo apt-get purge node -y
  2. Install the correct version of NodeJS for your flavour of Unix (NodeJS downloads, NodeSource Node.js binary distributions).
    • For Ubuntu, whose software repositories may run a few months behind the latest revisions, install NodeJS from an updated repository. For example, if Node 6 needs to be installed:
      wget -qO- | sudo bash -
      sudo apt-get install nodejs

      Refer to the Node and npm Versions section above for the correct version.
  3. Check that you installed node successfully and that it is the correct version:
    node --version
    • If that command tells you that node is not installed, your executable is probably called nodejs. Check its version, and if it is correct, link it to the name node:
      nodejs --version
      sudo ln -s `which nodejs` /usr/bin/node
  4. Installing NodeJS also installs npm. Check that that has been done and that the version is correct:
    npm --version
    • If you have any other version of npm, upgrade it to the correct version. For example, if npm 4 needs to be installed:
      sudo npm install -g npm@4
      Refer to the Node and npm Versions section above for the correct version.

Install Other Generic Requirements for Mac OS / Linux / Unix Edit

  1. Install MongoDB in the appropriate way for your version of Unix. It is recommended that, where possible, you follow MongoDB's official instructions which can be found at Install MongoDB Community Edition on Linux and Install MongoDB Community Edition on OS X. The instructions for Linux are broken down by distribution, so follow the appropriate link. For Ubuntu versions greater than 14.10, if the instructions have not yet been updated for your version, try one of these unofficial workarounds: workaround 1, workaround 2), but please assess them carefully to determine suitability for your system.
  2. Start the MongoDB server if it was not started during the installation process (the instructions above should tell you how).
  3. Install some npm packages globally:
    sudo npm install -g gulp grunt-cli bower mocha

Install Habitica-Specific Requirements for Mac OS / Linux / Unix Edit

  1. Install the Habitica-specific npm and bower packages:
    npm install
    • For OS X, if "npm install" gives a fatal error, install bower and npm separately:
      bower install; npm install
    • For any Unix OS, if "npm install" fails, try rerunning it again until it succeeds, clearing the npm cache first each time:
      npm cache clean; npm install
    • For OS X, if you see a "new worker (): fork" error, empty your Trash. This might be difficult if node is holding on to a file, so use the "rm" command to delete any items remaining in Trash.
  2. Follow the instructions in the Run Habitica section below.

Vagrant Edit

Vagrant is a system to create reproducible and portable development environments; it provides a single development environment with minimal dependencies on the developer's local platform.

You can use Vagrant on a variety of systems including Windows, Mac OS X, and Linux. These instructions are known to work well on Unix systems (Linux and Mac OS X), but Windows users can sometimes run into issues. If you do not have the option of using a Unix environment instead and run into issues setting up, file a bug on Github.

  1. Install the latest version of the free virtual machine software VirtualBox.
    (Previously, versions greater than 4.x didn't work well with Vagrant, so we were recommending that you install version 4.3, however Alys believes that issue is now resolved and that the most recent version of VirtualBox is best. If that doesn't seem to be the case for you, please ask about it in the Aspiring Blacksmiths (Habitica Coders) guild.)
  2. Install the latest version of Vagrant. The process below will automatically fetch a Vagrant box from; if you receive errors such as "The box 'thepeopleseason/habitrpg' could not be found" then you are not using the latest version of Vagrant and will need to upgrade it.
    Note: If you receive an error saying "The requested address is not valid in its context. - connect(2) for "" port 3000 (Errno::EADDRNOTAVAIL)", this could be due to a bug in Vagrant v1.9.3, which will be fixed on the next release. The temporary workaround is to downgrade to Vagrant v1.9.2.
  3. If your host machine is Windows, open a Command Prompt window with administrative rights. For other operating systems, open a terminal window.
  4. Copy the Vagrantfile from the example one:
    cp Vagrantfile.example Vagrantfile
  5. If desired, increase the amount of memory and number of CPUs allocated to the box by editing Vagrantfile and modifying the values for v.memory and v.cpus. When vagrant up is run the first time, scripts are executed to provision the virtual machine with software packages required for habitica. If any of these fail due to memory or cpu issues, run vagrant destroy and then restart the Vagrant setup from the next step. However memory and cpus can be changed after the first vagrant up has been successful by simply modifying the values and running vagrant reload (This might be helpful to allocate more memory and cpu for the initial setup and then reducing it for daily use). You may want to increase v.memory to avoid swap files, or decrease it if your computer does not have enough memory to allocate to the box. However, be aware that not allocating enough memory may lead to errors; see Important Notes above.
  6. Boot the Vagrant box (the first time you do this it can take 30 to 60 minutes):
    vagrant up
  7. Login to the environment (a Ubuntu Linux virtual machine):
    vagrant ssh
    • Before that command will work, your PATH variable must include the ssh program. This will already be correct for Unix, Linux, and Mac OS users. For Windows users, you most likely have ssh in the Git directory and if it's not already in your PATH, you can add it with:
      set PATH=%PATH%;C:\Program Files (x86)\Git\bin
  8. Check that the ssh command was successful and that you are now in the vagrant machine. If you are not, do not proceed further with these instructions until you have been able to ssh to the vagrant machine. If ssh was successful, the vagrant machine's prompt will be vagrant@habitrpg:/vagrant$
  9. Check that the correct versions of NodeJS and npm have been installed:
    node --version; npm --version
    • Refer to the Node and npm Versions section above for the versions that are needed.
    • If incorrect versions have been installed, please report it in the Aspiring Blacksmiths guild so that we can fix the vagrant install script. If you are not sure how to install the correct versions, you can ask for help there.
  10. Install required node modules (this will take many minutes):
    npm install
    • If an error occurs, run npm install a second time.
    • On a Windows host, you may need to run this with elevated permissions, and tell npm to install without making symlinks, to avoid errors: sudo npm install --no-bin-links. You may also need to install bcrypt manually: sudo npm install bcrypt.
    • If you still see error messages during the second time, please post in the Aspiring Blacksmiths (Habitica Coders) guild to report the problem. State that you ran it twice. We will give you advice about running each part of npm install individually (if you feel comfortable doing that yourself, you can, but please do post to the guild as well to help us track the occurrence of this problem).
  11. Run these commands:
    • bower install -f
    • gulp build
  12. Follow the instructions in the Run Habitica section below.

Note: In creating the Vagrant environment, a configuration option automatically changes the working directory to /vagrant (the location of the Habitica source) on login. If you do not wish to login to Vagrant with that default directory, edit /home/vagrant/.bashrc to remove the line ('cd /vagrant').

Note: In creating the Vagrant environment, a configuration option automatically exports the DISPLAY environment variable to :99 in /home/vagrant/.bashrc. This is needed in order to run the end-to-end (e2e) test suite. If you are not using bash you have to manually export the variable before running tests with: export DISPLAY=:99

Note: You can opt to have the initial "vagrant up" command start the entire system (i.e., run npm start). If you choose to do so, edit the file "vagrant_scripts/" in your habitica directory, and remove the "#" in front of the line autostart_habitrpg. Once the system is up and running, you will need to open another shell to run "vagrant ssh", and you won't be able to interactively reload the server. Because of these deficiencies, you should only autostart the server if you know what you're doing.


Docker allows development in containers requiring very little setup and asserting that everyone uses a consistent environment. It also means that you do not need to muddy up your host version with dependencies. Before beginning, follow the instructions for installing docker and docker-compose: .

Verify your installation by clicking the Docker Quickstart Terminal icon on your Desktop (Windows) or Launchpad (Mac OS X). Follow the directions above to install Git, fork a copy of the habitica repository, and clone it to your local machine. In the Docker Quickstart Terminal, cd to your local habitica folder.

Use docker-compose to build and start both the mongo database and habitica application Edit

The docker-compose.yml file will build a habitica container using the Dockerfile build file and pull the latest mongo image:
docker-compose up -d This will start two containers in the background.

$ docker ps

CONTAINER ID   IMAGE          COMMAND                  CREATED          STATUS          PORTS                        NAMES
4c9bcb599e97   habitica_web   "npm start"              31 seconds ago   Up 29 seconds>3000/tcp       habitica_web_1
80e79eae6ceb   mongo          "/ mongo"   28 minutes ago   Up 28 minutes>27017/tcp   habitica_mongo_1

Habitica is available on port 3000 and mongo is on port 27017. The version of Habitica running in habitica_web is branch:develop of the Habitica repository.

Note: The application files are stored in an ephemeral container so changes can be easily lost. It is safer and more convenient to mount your local clone of the Habitica repository in the container.

Bootstrap your local clone using the tools already installed in the container. Edit

  1. Use docker-compose again to stop these containers:
    docker-compose stop
  2. Then mount your local clone directory to the habitica_web container and bootstrap:
    docker run -t --volume `pwd`:/usr/src/habitrpg habitica_web npm install
    docker run -t --volume `pwd`:/usr/src/habitrpg habitica_web bower install --allow-root
  3. Run the containers using the local clone:
    docker-compose -f docker-compose.yml -f up -d

Now changes made to the local clone will be served via the container.

Note: The above step will create two containers in your machine.

$ docker ps -a
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS                      PORTS               NAMES
19c16247ff69        habitica_web        "bower install --a..."   4 minutes ago       Exited (0) 3 minutes ago                        infallible_darwin
515e370cc936        habitica_web        "npm install"            30 minutes ago      Exited (0) 26 minutes ago                       elastic_keller
81e8c7aa0181        habitica_web        "npm start"              44 minutes ago      Exited (0) 31 minutes ago                       habitica_web_1
6bd0dac0ba4c        mongo               "/ mo..."   4 weeks ago         Exited (0) 31 minutes ago                       habitica_mongo_1

These two containers will have random names like elastic_keller and can be removed with docker rm [container_name].

If you experience any errors when running npm commands, check that the correct versions of NodeJS and npm have been installed:
node --version; nodejs --version
Refer to the Node and npm Versions section above for the versions that are needed. If incorrect versions have been installed, please report it in the Aspiring Blacksmiths guild so that we can fix the docker configuration. If you are not sure how to install the correct versions, you can ask for help there.

Running tests in the docker Edit

Once you've started the two docker containers with docker-compose, you can attach to the hatibrpg_web container for test execution.

$ docker-compose exec web sh
# <--here's your bash

Now you are in the container, and you can execute test suites with

$ npm test

While creating unit test, you may also want to run a docker container that only run tests.

$ docker run --name habitica_test -it --volume `pwd`:/usr/src/habitrpg habitica_web gulp test:${your_test_category}:watch

The command above creates a container called habitica_test, which you can stop and start for running tests.

Use an existing mongodb instance instead of the mongo container Edit

To avoid the mongodb docker container and instead run Habitica against an existing mongodb instance, launch the habitica_web container with an override to the NODE_DB_URI environment variable:
docker run --env NODE_DB_URI=mongodb://your/database habitica_web, or
docker run --env NODE_DB_URI=mongodb://your_hostname/habitrpg habitica_web

Follow the instructions in the Run Habitica section below.


The configuration files for Uberspace have not been updated for APIv3. Please do not use till further notice.

A guide to installing Habitica on a Uberspace is available at

Please note that currently the main Habitica developers don't have experience with this Uberspace process and so they might not be able to assist you if you have problems while using it. However they have no objection to the use of it and you are welcome to ask for advice in the Aspiring Blacksmiths (Habitica Coders) guild or on GitHub as long as you keep this caveat in mind.

It is recommended that you first read the instructions at the top of this page (everything up to the "Instructions by Operating System" section) and follow them where necessary because they have been modified since the Uberspace process was written.

After following the Uberspace guide, follow the instructions in the Run Habitica section below.

Run HabiticaEdit

  1. Ensure that the MongoDB database server is running. It should be if you have just completed the above steps, but if you are returning to your local install after a break, it might need to be restarted; refer to online MongoDB instructions for your operating system or ask in the Aspiring Blacksmiths (Habitica Coders) guild if you need help.
  2. Ensure that the time set on your computer or virtual machine is accurate to the nearest second, otherwise you will see "RequestTimeTooSkewed" errors.
  3. Ensure you have copied config.json.example to config.json, as noted on the top of this page.
  4. In a command prompt or terminal window, compile various files and start a web server with:
    npm start and review the output.
    • Ignore these errors and warning messages:
      • Mongoose: mpromise (mongoose's default promise library) is deprecated, plug in your own promise library instead:
      • { [Error: Cannot find module '../build/Release/bson'] code: 'MODULE_NOT_FOUND' }
        js-bson: Failed to load c++ bson extension, using pure JS version
      • error: InvalidAccessKeyId: The AWS Access Key Id you provided does not exist in our records. (this will be followed by several lines starting with at and then a fullError message, ending with a retryDelay line).
    • Stylus hang

      Incomplete "npm start" (click to expand)

      If you see any other errors or warning messages, before going any further, resolve them yourself or report them using the guidelines in the Prepare for Troubleshooting section above. Note that even if the output ends with Done, without errors there can still be errors above it that need to be resolved, as in this screenshot. It is possible that the errors will stop if you hit Ctrl-C and run npm start again.
    • npm start has finished when you see a line similar to Finished 'grunt-build:dev' after 3.45 s
  5. Open a browser to http://localhost:3000 to test the application.
    • Note that "3000" is the default port used by the installation scripts, however if you have changed it in the "config.json" file, then you must change it in the URL too.
    • For Vagrant installations, if port 3000 was already in use by any service on your machine, Vagrant will have automatically selected another port between 3000 and 3050, and will have listed that port in its own output.
    • The output of npm start will confirm the port in use: info: Express server listening on port 3000. If you do not see that message, then npm start has not run correctly.
  6. If you get to the website's front page but the Play button does nothing, or if you get to the login screen but the login button does nothing, clear local storage for the "localhost" domain. You can do that by clicking the button at http://localhost:3000/static/clear-browser-data or by using your browser's JavaScript console (google for information about how to clear local storage in your preferred browser). Then reload the front page.
  7. Create one or more accounts for your testing. The database used by your local install is hosted on your machine; it is not the same database that is used by Habitica itself and so your normal Habitica account will not be available to you.

Next Steps: Using Your Local InstallEdit

Now that you have a working local install of the Habitica website, you can learn how to contribute code in Using Your Local Install to Modify Habitica's Website and API.

Also see Guidance for Blacksmiths, which has information about the technologies used, how the Habitica code is structured, ideas for how you can help, and other information.

Ad blocker interference detected!

Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.