Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set Node.js and NPM version numbers in a hosted VSO Build Agent?

In Visual Studio Online you can now set build dependencies on the General tab of a build definition.

enter image description here

But.. is there a way to set the version of Node.js and NPM?

It seems like a hosted build agent is currently using Node.js v0.12.7 and NPM v2.11.3 but I need Node.js v4.2+ and NPM v3.3+. Is there a way to enforce it?

P.S.: On-premise VSO build agent is not an option.

like image 753
Grief Coder Avatar asked Oct 15 '15 14:10

Grief Coder


People also ask

How do I force npm to specific version?

To prevent this, use --save-exact flag in addition to --save or --save-dev . This flag will force NPM to store the exact module version in the package.

How set Nodejs active version?

User CommandsUse the command n followed by the version number needed by the application. It is that simple. It's also possible to use the command n latest to use the current version of Node or n lts for the latest LTS version.

How do I specify Node version in package JSON?

Use the engines keyword in the package. json file to specify the Node. js version that you want your application to use. You can also specify a version range using npm notation.


2 Answers

There is now a Node Tool installer available. The link to software inventory shared by Daniel was very helpful, and I discovered the installer digging into the Node specs for Hosted VS2017 agent.

Finds or downloads and caches the specified version of Node.js and adds it to the PATH

Try adding a Node Tool installer step before your node/npm steps.

like image 104
stealththeninja Avatar answered Oct 30 '22 16:10

stealththeninja


It seems like there's a lot of misunderstanding as to what "demands" are. A build with a specific demand does not change what software is available on the build agent. A "demand" is simply a method of a build task expressing what requirements it has, so it can run on an agent that has the desired demands satisfied (these are the build agent's "capabilities").

This list of software is what's on the hosted build agent. If it's not there, and you can't install it via npm or the like, then you're out of luck.

like image 27
Daniel Mann Avatar answered Oct 30 '22 16:10

Daniel Mann