TFS or VSTS builds that contain npm tasks take a very long time on a private build agent.
As you can see in the image, each npm stept takes more then 6 minutes – even a npm config. If you run npm from the console the performance is normal.
If you look in the npm log there is a 3 minute gap between npm steps.
... 2017-07-20T11:25:42.9862610Z ; "npm config ls -l" to show all defaults. 2017-07-20T11:28:51.0460295Z ##[debug]rc:0 ... 2017-07-20T11:29:52.2615357Z npm info ok 2017-07-20T11:32:00.7048922Z ##[debug]rc:0
In my case I had a very new version of nodejs (8.2.0) installed on the build agent. The downgrade to the latest LTS (long term support) version (6.11.1) resolved the issue for me.
What’s important: this is not a general issue. I tried the version 8.2 on a azure build machine with vsts and had no issues. This seems related to the specific environment. But as long as there is no need to update nodejs I will stay on the latest LTS on my build machines. There is also a separate chocolatey package for lts versions of nodejs.
One thought on “Fix slow performance of npm tasks on TFS build agent”
You save my day! Worked great, Mike. Just a question, why a downgrade works，which part changes on the nodejs (8.2.0) cause the issue.