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:
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')
)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