Sunday, June 21, 2020

Installing Node and Angular CLI on Ubuntu

To create applications in Angular, the Angular Command Line Interface is required, which in turn requires Node to be installed. The installation is pretty straightforward, but following the stock instructions from Angular on Ubuntu gave me permission errors. So here is the process to install the required Node parts and the Angular CLI on Ubuntu to allow development of Angular apps.

Follow the steps below, or just watch this video:

First, install Node and the Node Package Manager from the Ubuntu repository. (Note: the versions in the repository are not the latest versions, and there are several ways to install newer versions on Ubuntu. But for the purposes of developing apps in Angular, the repository versions are generally fine.)

sudo apt-get install nodejs npm

This takes a bit of time, and when it is done you can check the versions installed to ensure that they are working correctly:

node --version
npm --version

Next we use npm to install the Angular CLI. First try the stock instructions from Angular, which say to do the following:

npm install -g @angular/cli

For me, this causes a permission error. Installing with sudo seems to resolve the problem, though:

sudo npm install -g @angular/cli

We can verify the installation with:

ng version

And now Angular CLI is ready for use

No comments:

Post a Comment