javascriptunixnode.js

How I trigger the "System Bell" in nodejs


I'm running a long running custom nodejs script and would like to be notified when the script is completed.

How do I make nodejs trigger the "System Bell"?


Solution

  • Output the BELL character (Unicode 0007) to the standard output.

    console.log('\u0007');
    

    Update 2023

    Solution above doesn't work anymore, but writing directly to stdout still works (tested on Node.js v14.20):

    process.stdout.write('\u0007');
    

    References