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

269
Vistas
Node.JS reading json file isn't displaying new file updates

I have two configuration files (log.txt, and config.json) that are updated after each computation and the next computation is dependent on the results of the previous computation which are stored in the two files. The problem is, when I read the json files during computation I only get the results of the initial first computation. The new updates are not reflected in the new file reads. But when I check the files, both have been updated. What could be the problem? Thanks in advance.

Script for Reading the configuration files (pFunctions.js):


const fs = require('fs');

// Read logs
function readLog() {
        
    try { 
        return fs.readFileSync(__dirname + '/' + 'log.txt', {'encoding':'utf8','flag':'rs+'});
    }
        
    catch (err) { 
        return '';
    }
        
}

// Read configurations
function readConfig() {
        
    try { 
        return fs.readFileSync(__dirname + '/' + 'config.json', {'encoding':'utf8','flag':'rs+'});
    }

    catch (err) { 
        return '';
    }

}

// Function to read dataset
function readDataset() {
       ....
       ....
}

// Read data from configuration files
let config = readConfig(); // config.json
let log = readLog(); // log.txt

// Parse data to JSON                    
let cfg = JSON.parse(config);
let lcg = JSON.parse(log);

....
....

// Fetch dataset based on the configuration and log file
let dataset = readDataset();

// Create parameter function
const pFunctions = {

    parameter1: dataset // set dataset as value of parameter1

}

// Export function as JSON Object
module.exports={pFunctions};

I then import the object in the computation.js script like this:

const {pFunctions} = require('./app/config/pFunctions');

// Capture new 'uParams' computing parameters
let newParams = pFunctions; 

about 4 years ago · Juan Pablo Isaza
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