32

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"?

DebugXYZ
  • 867
  • 1
  • 10
  • 17

2 Answers2

57

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

console.log('\u0007');

References

Paul Sweatte
  • 23,524
  • 7
  • 119
  • 253
13

The console.log('\u0007') didn't work for me running VSCode on windows 10. The following code did work:

import { exec } from 'child_process'
exec(`rundll32 user32.dll,MessageBeep`)
Ronen
  • 1,165
  • 12
  • 8
  • even if the `console.log` version worked for me, it did not work after building an electron app with the code. Your solution also works for electron apps on windows 10. – messerbill Dec 07 '20 at 20:13
  • one more case, use `>` redirect console output to a file – benbai123 Jul 01 '21 at 12:30