I had this exact problem and I just solved it by changing the account the build agent is working with. when you run the installer of the agent, you get the opportunity to use the system account or user account. I used the system account, but I installed node, npm and gulp under my user account so that the agent does not have access to it.
therefore, the quickest solution is to run the build agent installer again and finally select a user account to start the service in
source share