skip to Main Content

I am trying to setup locally an existing Heroku app. To do so, I git cloned the app from our repo in Github. Then I added the git remote for heroku.

Normally, builds to the server happen with Travis CI, but now I want to run the app locally straight from heroku.

heroku config returns the config variables just fine.

But heroku local web returns the error

throw new Error(‘Configuration property "’ + property + ‘" is not defined’);

Error: Configuration property "redis.url" is not defined

redis.js

import config from 'config';
const redis = new Redis(config.get('redis.url'), {
  keyPrefix: 'kw:',
});

The config folder is in the root of my repo.

config/default.js

import dotenv from 'dotenv';

dotenv.config({ silent: true });

module.exports = {
  ...,
  redis: {
    url: process.env.REDIS_URL || process.env.REDISCLOUD_URL,
  },
  ...
}

Relevant scripts in package.js

    "start:server": "./node_modules/.bin/babel-node src/server.js",
    "start:worker": "./node_modules/.bin/babel-node src/worker/worker.js",
    "start": "./node_modules/.bin/nf start",

If I run npm run start:server I get the same error.

If I comment out the redis.url code I get the same error but for another variable in the config.

What am I missing? Let me know if you require clarification.

2

Answers


  1. Chosen as BEST ANSWER

    I had to create a local .env file.

    I got confused because I was reading that you dont need a .env file with Heroku. But this is not the case for local setups it seems.


  2. heroku config -s > .env

    will copy those files to the local .env it seems. seems strange that this isn’t the default, but so it goes.

    Once you do that, run your app with heroku local.

    I found the answer here: https://www.debugcn.com/en/article/31153943.html

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search