Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

244
Views
npm unexpected token / in config.json at position 98

I have seen several unexpected token errors related to npm but this one is yet again unique to me. I could not find any similar issues posted by others. My config file just has connection objects to my local mongodb, rabbitmq "amqp", wordpress plugin and mysql DB.

Could anyone help me with this error in case they've seen it before?

C:\xampp\htdocs\livetrader\chat\node_modules\nconf\lib\nconf\stores\file.js:160
throw new Error("Error parsing your configuration file: [" + this.file + ']: ' + ex.message);
^

Error: Error parsing your configuration file:     
[C:\xampp\htdocs\livetrader\chat/config.json]: Unexpected token / in JSON at position 98

Updating this post with the config.json file referenced in this error

{
  "port": 1337,
  "mongoose": {
    "uri": "mongodb://localhost:27017/livetrader"
  },

  "amqp":{
    "uri": "amqp://guest:guest@localhost:15672",
    "queue": "TickData"
  },

  "sql":{
    "host":"localhost",
    "database":"db_main",
    "user":"root",
    "password":""
  },

  "wp":{
    "host":"http://forextrader.dev",
    "LOGGED_IN_KEY":"MY_LOGGED_IN_KEY",
    "LOGGED_IN_SALT":"MY_LOGGED_IN_SALT",
    "prefix":"wp_",
    "avatarPath":"http://localhost/livetrader/wp-content/uploads/avatars",
    "myCreedApi":"MY_API_KEY"
  },

  "guest":{
   "cookie_name": "trading-forex-guest",
   "ttl": 180
 }
}

Updating the back-end config path

"use strict";

var nconf = require('nconf');

nconf.argv()
    .env()
    .file({
        file: process.cwd() + '/config.json'
    });

module.exports = nconf;
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Your JSON file is property formatted. JSON.parse() takes it, no problem. Character 98 is not a slash, either.

There is, however, a suspicious slash in your path:

C:\xampp\htdocs\livetrader\chat/config.json

The final slash is unix-style, not windows-style. Could that be causing the problem?

If that's not it, you must be reading the wrong file, or passing it the wrong way to a function. Try using console.log to figure out what exactly is reaching JSON.parse().

Giving objects to JSON.parse() can cause unexpected errors, since .toString() is invoked. For example:

> JSON.parse({a:1})
SyntaxError: Unexpected token o in JSON at position 1

> ({a:1}).toString()
'[object Object]'

So, to recap, you must be:

  1. Reading the wrong file
  2. Passing an object that's not a String to JSON.parse()
  3. Having a strange problem with the inverted slash in the path
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!