0

I have a date module that returns current date that is set in system:

function getDateFormatAndISODate() {
    const dates = require('./resources/getSystemDate').getSystemDate();
    return dates;
}
module.exports.getDateFormatAndISODate = getDateFormatAndISODate;

I am requiring it in another file:

import * as isoDateModule from './datastream-get-iso-module';

The issue is the method call is not returning new date values when user changes the date manually from system and call this method again:

isoDateModule.getDateFormatAndISODate(dateVal);

I am using c node addon in my project and I am requiring it like this:

function requireUncached(module) {
    delete require.cache[require.resolve(module)];
    return require(module);
}

const dates = requireUncached('./resources/getSystemDate').getSystemDate();

But still I get the old date values. Not sure whats missing

kittu
  • 6,662
  • 21
  • 91
  • 185
  • It looks like you are passing `userDate` to your `getDateFormatAndISODate` function but not using it anywhere in the function itself – Jason Roman May 15 '20 at 17:13
  • 1
    @JasonRoman That was just a snippet of my code. I am using it. Issue is something else – kittu May 15 '20 at 17:21
  • Did you try take a look into what exactly TypeScript has codegenerated? Maybe some of its optimizations decided to optimize it somehow that breaks your code? – Eugene Obrezkov May 15 '20 at 17:33
  • @EugeneObrezkov its creating `Object.defineProperty(exports, "__esModule", { value: true });` file – kittu May 15 '20 at 17:51
  • @EugeneObrezkov updated the question – kittu May 15 '20 at 18:27
  • 1
    It's hard to say what is happening without more info. EPERM error means that you are not the owner of the specified file and unlink means that it is trying to remove the file. What exactly and why is it happening, it can be totally on your side with some specific setup. – Eugene Obrezkov May 15 '20 at 18:51

0 Answers0