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

In Visual Studio Online you can now set build dependencies on the General tab of a build definition.
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.

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.

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.

Related

NPM CI Cross-Platform Reliability

Our NodeJS application should run on Linux and Windows servers. We have the following dilemma:
If we run npm i as our CI Build then we sometimes get errors due to differences between the developers laptop's NPM and the build server.
However, if we run npm ci then the build will presumably be locked to the platform of the developers laptop (Windows) and not work on a linux build server.
Maybe our assumptions are incorrect:
Do we need to build 2 versions of our app: one for each platform?
Does npm ci lock us into the platform of the developer's machine through package-lock.json?
Examples of builds working on developers Windows laptops and on Windows servers but not on a Linux server are apps like strapi or packages like sharp which compile stuff for the platform (.dlls for windows, godknowswhat for linux).
Apparently there is no portable way to create a portable node_modules folder, even if all dependencies are pure javascript ones.
I found this the hard way as it seems that npm created different scripts on Windows, like ones ending in .ps1, something that does not happen on POSIX platforms.
That means, that no way to track node_modules in git either.

Update TFS2017 task to latest version

I am working on a build to run a powershell script on a remote machine, using the VSTS task :
I currently am using TFS2017 on premise, and this is version 1 of that task.
There is a version 3 available on github here :
https://github.com/Microsoft/azure-pipelines-tasks/tree/master/Tasks/PowerShellOnTargetMachinesV3
I am having an issue with this task failing, and I have read elsewhere that this version has a fix for my issue, so I want to update it if possible.
I tried a few ways to do this, but I cannot work out what I am supposed to be doing. You would think there would be an update button in TFS!
Well, there is, but it requests that you provide a .VISX file. Which the repo in GIT does not have.
I've tried running the steps in this other post:
How to update the built-in Microsoft task library in TFS 2017?
But running the command "npm run package -- --version " doesn't generate the VISX.
I tried running :
npm run package --PowerShellOnTargetMachinesV3 --version 3.1.3
That responds with the output:
5.6.0
Which I am not sure what to do with!
I have seen another post that says I need to use the tfs-cli?
I'm very confused.
Any help is appreciated!
Since you are working on TFS on-premise, the task version will not auto update. You need to manually install "PowerShell on Target Machines" task version 3.0
You just need to download the source code and package it as an extension, finally upload and install your extension. There are some steps updated:
Get the package tool (tfx-cli)
You can install or update the TFS Cross Platform Command Line Interface (tfx-cli) using npm, a component of Node.js, from your command line.
npm i -g tfx-cli
Package your extension in a .vsix file
tfx extension create --manifest-globs vss-extension.json
More details please refer this official tutorial: Package, publish extensions.

TFS 2017 CI with Gulp

I have just set up a TFS 2017 server and am trying to go through the CI tutorial at https://learn.microsoft.com/en-us/vsts/build-release/apps/nodejs/build-gulp?tabs=vsts but am having trouble on the Gulp task. I am getting the error "Not found node: null". I am using an ubuntu agent with the most recent versions of node, npm, and gulp installed. All the tasks are configured exactly as described in the tutorial.
The error usually means you have an environment issue , such as node couldn't captured by TFS build agent.
For the Default agent queue:
VSTS: Select Hosted VS2017. This is how you can use our pool of agents that have the software you need to build your app.
TFS: Select a queue that includes a Windows build agent.
Source Link
If you are working with linux build agent, you need to use windows build agent instead of ubuntu(linux build) agent.
If you are working with windows agent, make sure the node, npm, and gulp installed before TFS build agent configured, otherwise the new capability will not captured.
You need to reconfigure the build agent or restart VSO agent service. Besides make sure your working directory of Gulp task is getting set properly.
I ended up uninstalling and reinstalling nodejs and npm. I believe the problem was that TFS did not sense the node.js and npm capabilities because I originally installed them using nvm, so the second time around I installed using apt packages and everything worked fine.

How do I install Brackets IDE from behind a firewall on Linux?

We are behind a firewall.
We have a self-hosted central npm repository, that doesn't have all the packages (most, but not all).
It seems the grunt build process (to compile from source) relies on phantomjs to be built via npm. I have phantomjs 1.9.2 built from source and available, but the process specifies that it needs to be installed via npm to work.
My goal is to build so I can use the IDE in my environment. There is a .app, and a .msi available for Wndows and Mac, but for Linux I have to compile from source (we have a .deb, but I'm on CentOS).
Any help is appreciated.
It looks like you don't actually need PhantomJS for building Brackets -- I see it's a dependency in the package.json, but I don't actually see a mention in the Brackets source code where it may be called.
So could you just try building Brackets without having PhantomJS installed and see if it works?

Nexus equivalent for web development

I've been using Maven and Nexus for Java backend development for quite some time, with very good results.
With web development, I started using the "usual suspects": Bower, Yeoman, NPM, Grunt, ...
What is the best way to managed project dependencies? I'd love to install a Nexus equivalent that would allow me not to download the dependencies for each project.
Thanks for your help! :)
I've not tried that, but bower can do that. You can host a private bower registry.
Here is some links you could be interrested with :
http://toranbillups.com/blog/archive/2013/08/04/How-to-host-a-private-bower-registry/
https://github.com/bower/registry
For your NPM needs you can continue to use Nexus, as NPM support is part of Nexus OSS and PRO and allows for proxying, hosting and grouping. Check out the documentation and a video demo for more information.

Resources