On each Azure Pipelines agent docker image, there is installed node.js in special directory. You can utilize this one for your task, so there isn't necessary to install node.js into your build machine.
Node is currently in version 10 in special directory
/azp/agent/externals/node10" inside Azure Pipelines agent.
For runninng your node.js scripts directly
- Adjust the PATH environment variable in first pipeline Bash task, use this inline code
# adjust PATH variable, is preserved for subsequent tasks echo "##vso[task.setvariable variable=PATH]$PATH:/azp/agent/externals/node10/bin"