Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

239
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda