Home > Software engineering >  NPM module system-sleep sleeps forever
NPM module system-sleep sleeps forever

Time:12-02

My code is very simple. But only 0 is printed. sleep sleeps forever :( What is the mistake I am failing to notice???

import sleep from 'system-sleep';
function starti()
{
    for (var y = 0; y < 10; y  ) {
        console.log(y);
        sleep(1000);
    }
}

starti()

CodePudding user response:

I think the problem is in the 'system-sleep' library, this could happen for two reasons:

  1. you're using this as es-module, I've tried both type (common-js en es-module) and the common-js type work properly ( var sleep = require('system-sleep') )

  2. you're using node >= 14, that seems to broke the library :(

Since you're not doing nothing wrong, I suggest you to change the library

  • Related