DEV Community


Posted on

Installing a github server/database project locally

On the Founders and Coders course, we make a new project each week, and then each team spends time at the end of the week reviewing the code of another team's project.

When testing the projects (especially if the team hasn't managed to deploy them in our quick sprints-- which definitely happens-- it's the learning, not the finished product that matters!), we often want to install them locally and it confused me a couple of times so I've written it down. I hope you find it helpful, too!

Clone & install dependencies

Clone this repo to a new folder on your local machine using  git clone + the HTTP link from the Code dropdown menu in the project. Move in to the folder with cd + folder name

First, we want to:

  • Run npm install in your terminal to install all npm packages

Initialise a local database

Now we need to to create a local database for testing and connect to it with the project's init.sql file.


  • psql to enter into the postgres terminal
  • CREATE USER myuser SUPERUSER PASSWORD 'mypassword'; to create a dedicated psql local user for the application
  • CREATE DATABASE test_database WITH OWNER myuser; to create a database
  • \connect test_database to connect to your test database file
  • \include init.sql to initialise and run the sql file
  • handy hint: ctrl + d at any time while running psql in the terminal to get out of it

Create environment variables in a .env

Next, set up your own environment variables for the JSON secret key, database_url and test_database_url (if applicable)

  • Create an .env file in the very root of the project, the top file. It won't work anywhere else!

    Add the following to this file:

    • DATABASE_URL = "remote Heroku URI", if applicable

    The Heroku config variables will be in the 'settings' section of your app, at a url like this:

    • TEST_DATABASE_URL = "postgres://username:password@localhost:5432/database_name" - sub in the details we created earlier
    • SECRET- a secret key which will be used to create a JSON Web Token (JWT) for storing cookies
  • Now we can run it using commands in our terminal. Check the package.json file under 'scripts' to see the project-specific commands, but they are likely to be:

    • npm run dev to start the server using nodemon. Nodemon auto restarts anytime you change something, so you don't have to do it!
    • npm test to run tests locally if there are tests to run

And you're good to go! If I've missed something, let me know. 🐙

Top comments (0)