James Blackburn
James Blackburn

Reputation: 616

Azure Devops VSTS build agent using different version of Node

Locally the project I have runs fine and the npm install command completes successfully. I am using Node 11.5 and recently installed file-loader with no issues.

However when I pushed the build to VSTS and it ran the 'npm install' command I noticed in the log output that for some reason its using Node 12.13 whereas up until this point it had been Node 11.5. The command did not finish successfully and failed with the following:

gyp ERR! build error 
gyp ERR! stack Error: `C:\Program Files (x86)\Microsoft Visual 
Studio\2017\Enterprise\MSBuild\15.0\Bin\MSBuild.exe` failed with exit code: 
1
gyp ERR! stack     at ChildProcess.onExit 
(D:\a\1\s\Navico.Global\Navico.Global.Web\node_modules\node- 
gyp\lib\build.js:262:23)
   gyp ERR! stack     at ChildProcess.emit (events.js:210:5)
gyp ERR! stack     at Process.ChildProcess._handle.onexit 
 (internal/child_process.js:272:12)
gyp ERR! System Windows_NT 10.0.14393
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" 
"D:\\a\\1\\s\\Navico.Global\\Navico.Global.Web\\node_modules\\node- 
gyp\\bin\\node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "-- 
libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
 gyp ERR! cwd D:\a\1\s\Navico.Global\Navico.Global.Web\node_modules\node- 
sass
gyp ERR! node -v v12.13.0
gyp ERR! node-gyp -v v3.8.0
 gyp ERR! not ok 
Build failed with error code: 1
npm verb lifecycle [email protected]~postinstall: unsafe-perm in lifecycle true

What I have tried so far:

I am guessing something recently added (file-loader) is causing something to tell the build agent on VSTS to use Node 12.13 instead of 11.5 but not sure where to look. I am new to VSTS I have used TeamCity before and if we ever had any issues with build agents we could just remote onto the agent and fix the issue but not sure how/if that is possible in VSTS.

Any help will be greatly appreciated!

Thanks, James

Upvotes: 2

Views: 3514

Answers (3)

Venkata K. C. Tata
Venkata K. C. Tata

Reputation: 5547

I deleted package-lock and pushed changes and the build works as expected

Upvotes: 0

Chris Kooken
Chris Kooken

Reputation: 33938

I was having a similar problem. I tried the above answer and was still having an issue. Once I changed the solution in VSTS to build with VS2017 instead of "latest" my build started working again. enter image description here

Looks like Microsoft recently upgraded tooling on their hosted agent.

Upvotes: 1

Remco Brilstra
Remco Brilstra

Reputation: 828

If you want to sure about the version of node that is being used during your build add the 'Node.js tool Installer' task. in the task you can define the exact version of node that will be used. this will make sure that your build will run more predictably in the future regardless of changes to the default version used by the Microsoft agents.

enter image description here

Upvotes: 2

Related Questions