Skip to content

Loopback still requires config.json in order to load config.local.js or config.{env}.js #827

Closed

Description

@simoami

This can be seen in the loopback-boot code below:

config-loader.js

function findConfigFiles(appRootDir, env, name) {
  var master = ifExists(name + '.json');
  if (!master) return [];  <--------------- PROBLEM:  if json file doesn't exist other candidates don't matter.

  var candidates = [
    master,
    ifExistsWithAnyExt(name + '.local'),
    ifExistsWithAnyExt(name + '.' + env)
  ];

  return candidates.filter(function(c) { return c !== undefined; });
  ...
}

Suggested fix:

function findConfigFiles(appRootDir, env, name) {
  var candidates = [];
  var master = ifExists(name + '.json');
  if (master) {
    candidates.push(master);
  }
  candidates.push(
    ifExistsWithAnyExt(name + '.local'),
    ifExistsWithAnyExt(name + '.' + env)
  );

  return candidates.filter(function(c) { return c !== undefined; });
  ...
}

The same might apply to model and data source config file loaders.

Activity

  1. simoami commented on Nov 18, 2014

    @simoami
    Author

    To get around the issue, I had to create a dummy config.json file:

    config.json

    {}
    
  2. changed the title [-]app still requires config.json before it can load config.local.js or config.{env}.js[/-] [+]App still requires config.json before it can load config.local.js or config.{env}.js[/+] on Nov 18, 2014
  3. changed the title [-]App still requires config.json before it can load config.local.js or config.{env}.js[/-] [+]Loopback still requires config.json in order to load config.local.js or config.{env}.js[/+] on Nov 18, 2014
  4. self-assigned this
    on Dec 2, 2015
  5. loay commented on Dec 2, 2015

    @loay
    Contributor

    Hi @simoami
    Still having a problem with the same issue?

    Thanks.

  6. loay commented on Dec 9, 2015

    @loay
    Contributor

    Closing due to inactivity. If you are still running into problems, feel free to leave a comment and I will reopen the issue.

  7. dongmai commented on Dec 27, 2016

    @dongmai

    same with datasources.js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions