Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

238
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda