I have set up a VSO agent using an Azure VM and the Visual Studio Release plugin on Azure. I have also installed the latest version of node.js (using NVM for windows). I used the default account when installing the VSO agent as the credentials I used for remote desktop would not work.
I can remote into the machine and run the build script I am trying to run from VSO. I can also run purely .NET builds with it and its fine. My issues comes in using npm to install my packages and run the build.
I have set up a demand on the build like so:
npm | exists
I have set up a capability on the VSO agent from the control panel like so:
npm | C:\Program Files\nodejs\npm.cmd
Have also tried
npm | C:\Program Files\nodejs
I can see npm.cmd in that folder and I can run npm when I remote in using that path. I have also restarted the VSO Agent service as per this question:
TFS build agent cannot locate npm
Restarted the server and also done the "update all agents" a few times. I have also got npm in my path and am able to execute it normally when logged in.
Edit:
Error message:
npm : The term 'npm' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the
spelling of the name, or if a path was included, verify that the path is correct and try again.
At C:\work-folder\1\s\azure-deploy.ps1:24 char:1
+ npm update
+ ~~~
+ CategoryInfo : ObjectNotFound: (npm:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
I have also tried adding the line as described below:
$env:Path += ";C:\Program Files\nodejs\"
Same error. A Write-Host
of my $env:Path write after that command gives:
C:\Application Intallers\agent (1)\agent\worker\Modules\Microsoft.TeamFoundation.DistributedTask.Task.Internal\NativeBinaries\amd64;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Microsoft\Web Platform Installer\;C:\Users\propertyplotdev\AppData\Roaming\nvm;C:\Program Files\nodejs;C:\Program Files\Git\cmd;C:\Program Files\Git\mingw64\bin;C:\Program Files\Git\usr\bin;C:\Program Files\Microsoft SQL Server\120\Tools\Binn\;C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\;C:\Program Files (x86)\Microsoft SDKs\Azure\CLI\wbin;C:\Program Files (x86)\Microsoft SDKs\Azure\AzCopy;C:\Program Files\nodejs;C:\Windows\ServiceProfiles\LocalService\.dnx\runtimes\dnx-clr-win-x86.1.0.0-rc1-update1\bin;C:\Windows\ServiceProfiles\LocalService\.dnx\bin;C:\Program Files\nodejs\
Both C:\Program Files\nodejs\npm.cmd
and C:\Program Files\nodejs\node.js
exist and NETWORK SERVICE has permission on them. (As well as Adiministrators, SYSTEM and my login)
The solution to this was to install node.js with the regular installer :
https://nodejs.org/en/download/
This then worked. Still have other issues but the direct issue in this question is solved by not using nvm to install node. I could then add an npm task in the VSO build definition interface.