Getting Bower on my Private Agent

I was working on a blog post for releasing ASP.NET Core RC2 Web Applications with Visual Studio Team Services. During the build, you have to issue a publish command to build the directory that will be hosted in your web server.  When I executed that command, I got the following error:

2016-05-17T16:00:09.9639047Z No executable found matching command "bower"

This should be easy enough to fix. I will just remote into my build agent and use NPM to install bower.  Whenever I create a build machine, I start with a Azure VM using the latest Visual Studio Community template.  That image already has a version of NPM on it (as of this writing that version is 2.7.4). NPM revs very quickly and I wanted to update it first.  To update NPM you can actually use NPM.  Just issue the following command:

npm install -g npm@latest

At the time of this writing the latest version was 3.9.0 that appears to install correctly.


However, when I check the version I still see 2.7.4.  At this point I figured I would just install the latest version of Node.js that ships with NPM from here. The version of Node.js on my build machine was really old version v0.12.2 when the latest version was v6.1.0!  So I was glad I decided to check and upgrade Node.js as well. Simply download and install the latest version of Node.js. I used all the default values during the installation.

At this point I close any open command prompts and reopen them so the recent installations take effect.  When I check the versions of NPM and Node.js they are the same as before!


This is a serious problem because if I do not see the newer version my agent will not either.  I decide to search my machine for node.exe to make sure my installation was actually successful. That is when I noticed there are multiple copies of Node.js installed on the machine.


So I decided to uninstall the older versions using Programs and Features. However, only the must current version of Node.js was listed.


With no way to uninstall the older versions, I had to make sure the new version would be found instead.  When I analyzed my path variable, I noticed the folder to the desired version of Node.js was last and earlier in the variable was a folder to the older version.


To fix this we need to update the path environment variable.

  1. Open Windows Explorer
  2. Right-click the PC node
  3. Select Properties
  4. Click the Advanced system settings link
  5. Click the Environment Variables button
  6. Double-click Path in the System variables list
    You have two options:
    1. Delete the portion of the path to the wrong version “C:\Program Files (x86)\nodejs\;”
    2. Move the folder to the desired version earlier in the path. If you move it, be sure to add a semicolon to the end “C:\Program Files\nodejs\;”
  7. Click OK
  8. Click OK
  9. Click OK

Close any open command prompts and open a new one.  When you check the version, you should see the latest version.


With that taken care of we can install bower with the following command:

npm install -g bower

While you are here you might as well install gulp as well.

npm install -g gulp


This agent is now one step closer to building, publishing, and releasing a ASP.NET Core RC2 Web Application.

Comments (4) -

  • Brendan Green

    6/27/2016 11:23:08 AM | Reply

    Excellent post - I've been doing the same thing, but it seems that for me, even if I get bower installed AND callable from the prompt, my build ALWAYS fails with the same error regardless! About to pull what little hair I have out - are there possible steps that you have not documented that I have missed?

    • Donovan Brown

      6/27/2016 2:00:23 PM | Reply

      1. Make sure and use -g when you install
      2. Restart your agent after you do. If you are running interactive you have to close the command prompt completely.  

    • Paul Baxter

      7/8/2016 12:43:51 PM | Reply

      You may well have the same problem as me. As the modules are installed under a particular user's directory they will not be available to the agent if it's running as NETWORK SERVICE.

      I have created a directory c:\npm to store the modules in and added it to my path variable.

      You then have 2 options:
      1. Set an environment variable NPM_CONFIG_PREFIX=c:\npm 2. When installing the module npm install bower -g --prefix c:\npm

      Restart the agent (entire machine to ensure that it picks up the new path variable) and you should find that correct paths to bower and gulp appear VSTS and the publish command now works.

      • Brendan Green

        8/29/2016 10:14:55 AM | Reply

        Paul / Donovan,

        Thanks for the replies.

        Paul - nail on the head.  I discovered this myself and as you suggested I ran:

           npm install bower --prefix c:\npm
           npm install gulp --prefix c:\npm

        I then added c:\npm to the *system* path, rebooted and all was golden.

        BTW, I did this on a brand new Azure VM that I'd recently spun up as a secondary build agent - simply installed VS 2015, did the NPM install for gulp and bower and was happily building.

Add comment