Finally figured out the cause of the problem, and fixed!
Mac scripting with AppleScript (no problem with JS) was failing in my system.
$ osascript -e 'tell app "Finder" to display dialog "Hello, World!"'
osascript: can't open default scripting component.
Then my search landed up on this post on reddit. Just like mentioned in that post an audio plugin was the cause! 🤦♂️ The plugin is installed since 2017. No idea, why the problem started now.
I deleted the plugin. Everything started working!