0

I have this simple local.JSON file I use with node-config:

{

  "MySQL": {
    "connection": "mysql://root:foo@localhost/heroku_d093ad5a46d841c?reconnect=true",
  },

  "Mongoose": {
    "connection": "mongodb://localhost/myapp"
  }

}

However, I get this error from nodemon:

Error: Cannot parse config file: '/Users/foo/root/repo_fave/config/local.json': SyntaxError: Unexpected token } in JSON at position 110

Particularly what does the 110 refer to. Is it the 110th character if the file was treated as a single line of string?

  • Possible duplicate of [Can you use a trailing comma in a JSON object?](https://stackoverflow.com/questions/201782/can-you-use-a-trailing-comma-in-a-json-object) – Ele Apr 01 '18 at 21:20

1 Answers1

1

There is a typo in your JSON. In the MySQL block you have:

"MySQL": {
  "connection": "mysql://root:foo@localhost/heroku_d093ad5a46d841c?reconnect=true",
},

This should be:

"MySQL": {
  "connection": "mysql://root:foo@localhost/heroku_d093ad5a46d841c?reconnect=true"
},

Please note the removed comma at the end of the inner line. And yes, the 110 refers to the 110th character.

PS: To figure out what problems like these are, you might be interested in JSONLint, a website to validate (and find errors in) JSON.

Golo Roden
  • 140,679
  • 96
  • 298
  • 425