Fix slow performance of npm tasks on TFS build agent

Problem

TFS or VSTS builds that contain npm tasks take a very long time on a private build agent.

slow_npm_on_tfs_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.

fast_npm_on_tfs_build_agent_console

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

Solution

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.

3_fast_npm_on_tfs_build_agent_with_nodejs_lts

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.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s