Running apps locally - green-cani/green_tracker GitHub Wiki

[This is a resume of https://devcenter.heroku.com/articles/heroku-local]

Basic commands

To run the app, once configuration has been done, it is sufficient to type heroku local web, which runs the web process (as is by now defined in Procfile, it is equivalent to run node index.js). Issues with older versions of Node.js have been noticed; if you want to use a version of Node.js different from the one listed by which node, you can run path-to-alter-node index.js

Basic configuration

Please pay attention to this: the .env file shouldn't be committed to remote repositories, be sure to have it ignored in .gitignore! It should look like this:

DATABASE_URL='postgres://username:password@localhost/databasename'
DB_NAME='databasename'
DB_USER='username'
DB_PW='password'
TOKEN='...'

where the credentials refer to the local configuration of psql; the toke is of the form 'A:B' where A is the bot id and B is its token. An example is in envsample.

To have the same configuration both on Heroku and locally, run heroku config:get CONFIG-VAR-NAME -s >> .env.

Postgres configuration

Basic configuration doesn't cover the postgres username and password. [See https://devcenter.heroku.com/articles/heroku-postgresql] If the simple export DATABASE_URL=postgres://$(whoami) doesn't work, do the following:

  • with npm, install dotenv: npm install dotenv --save
  • insert in the code require('dotenv').load()
  • configure the database (see LINK)
  • in .env, write DATABASE_URL='postgres://usrname:passw@localhost/dbname'
  • ...