Actually, I have PhpStorm, but I think everything will work in WebStorm.
Run on the command line
cd <path to Gruntfile> node --debug-brk=64005 $(which grunt) img2base64
Where img2base64 - the name of the desired task.You can omit this parameter to start all tasks. We get debugger listening on port 64005 Further in WebStorm : Run → Edit configurations… → + → Node JS Remote Debug. Specify the configuration name (for example, grunt), Host: 127.0.0.1, Debug port: 64005 (the port can be set from 1025 to 65535, the main thing is the same everywhere ). Click OK. Set a breakpoint and click the Debug button. Profit! This is what the window looks like when debugging