Skip to main content

Jenkins: Add Angular Build Support

Here are steps to perform on a Jenkins build server, so it's capable of building Angular Apps and libraries.

Housekeeping

A few things to note about these steps:

These steps are aligned for an Ubuntu 22 host, so they may require adjustment for other distros and versions.

These are designed for a build server that will be able to build for versions of Angular.
So, we use NVM to manage Node.js, as different Angular versions are compatible with non-overlapping Node.js versions.

Steps

Remove Existing Angular Versions

This command will indicate what Angular version is active for the session: ng version

If installed, you will see this:

image.png

But, the above command could be responding to a locally scoped Angular version.

So, instead. We want to see what's globally installed, with this:
npm list -g --depth=0

If Angular is installed globally, it will appear in the output, like this:

image.png

If Angular is globally installed, you can remove it with this: sudo npm uninstall -g @angular/cli

Once removed, you can confirm it with the same command that listed it: sudo npm uninstall -g @angular/cli

And, it should be missing from the output:

image.png

Now, run this to see if Angular is still installed: ng version

If it returns an Angular banner, then you need to be more drastic.

Run this, to see where Angular is installed: which ng

If installed, you will see something like this:

image.png

Remove via Package Managers

Check if Angular is installed, via Snap:

snap list | grep angular

If installed, remove it with this:

sudo snap remove angular-cli

Check for other package manager installations:

dpkg -l | grep angular

If found, remove with this:

sudo apt remove --purge angular-cli -y
Manual Removal

You can manually remove Angular with this:

sudo rm -rf $(which ng)

Or, if you installed Angular under npm root -g run these:

sudo rm -rf /usr/local/lib/node_modules/@angular
sudo rm -rf /usr/local/bin/ng

Now, a call to this should fail: ng version

Preparing for Node.js

Building Angular apps and libraries may require multiple versions of Angular.
This may require multiple versions of Node.js.

So, follow these pages, to install Node.js on the build server:

Remove any existing Node.js versions with the removal steps from here: Installing Node.js on Ubuntu

Follow this to install NVM, to allow the install of multiple versions of Node.js: NVM - Node.js Version Manager