Giter Site home page Giter Site logo

Comments (9)

frankcarey avatar frankcarey commented on July 20, 2024

yeah, this is a real PITA at the moment. I added a try catch to output the filename, but I'm not getting any line numbers so it's still a trial and error process for me at the moment. Any better ideas to at least get tke line number?

function loadConfigFiles(files) {
  return files.map(function(f) {
    try {
      var config = require(f);
      Object.defineProperty(config, '_filename', {
        enumerable: false,
        value: f
      });
      return config;
    }
    catch(err) {
     console.log("Error loading config file %s: %s", f, err);
     throw err;
    }
  });
}

from loopback-boot.

raymondfeng avatar raymondfeng commented on July 20, 2024

Do you refer to JSON files?

from loopback-boot.

frankcarey avatar frankcarey commented on July 20, 2024

Yes, I'm getting the error with the datasources file. It seems like it might be cached between server restarts.. is that possible?

from loopback-boot.

raymondfeng avatar raymondfeng commented on July 20, 2024

datasources.json is persistent. It will be reloaded upon server start.

from loopback-boot.

bajtos avatar bajtos commented on July 20, 2024

It would be also nice to include more details when a JSON file is malformed. Is there any widely-used replacement for JSON.parse? I found greatjson, but that project seems to be dead. jju seems to be more popular, but it implements JSON5.

from loopback-boot.

frankcarey avatar frankcarey commented on July 20, 2024

I'm at a loss.. I can't seem to make sense of this syntax error :/

My local JSLint in vim has no issues or this online validator: http://jsonlint.com/

It all started when pasting in code from the loopback-connector-rest example, so I'm thinking maybe an odd character?

Error loading config file ../server/datasources.json: SyntaxError: ../server/datasources.json: Unexpected token

../node_modules/loopback-boot/lib/config-loader.js:100

from loopback-boot.

frankcarey avatar frankcarey commented on July 20, 2024

Note that I just copied the text from the linter BACK into the file, and now I don't get the error.

from loopback-boot.

frankcarey avatar frankcarey commented on July 20, 2024

@bajtos another side note about node-config is that it allows for comments in json files, which for config is really handy. That might be an easy feature to add as well and would help to debug by commenting out.

from loopback-boot.

dhmlau avatar dhmlau commented on July 20, 2024

Since the last comment was from almost 4 years ago, Closing due to inactivity. Please create a new issue if you are still running into problems.

from loopback-boot.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.