Step 1: Update Ubuntu
Straight off the bat, log in to your instance and update the package index as follows.
$ sudo apt update
With the package index updated, proceed to the next step.
Step 2: Install NodeJS on Ubuntu
$ sudo apt install -y curl
After that, download node setup from source using the following script. Execute the command:
$ curl -fsSL https://deb.nodesource.com/setup_16.x | sudo -E bash -
After this, install nodeJS as shown:
$ sudo apt install -y nodejs
Thereafter, execute the command shown to install the latest version of npm.
$ sudo npm install npm@latest -g
Confirm the npm and node are installed with the command:
$ npm -v
$ node -v
Step 3: Install AngularJS
With npm is installed, we can proceed to install AngularJS on Ubuntu using then npm command:
$ sudo npm install -g @angular/cli
The installation will take a few minutes to complete. Once done , check the version of AngularJS as follows:
$ ng version
The above Angular CLI will be displayed.
Step 4: Create Angular Application
Now that Angular is successfully installed on the system, we can go ahead and create our first angular application. First, create an application with the command:
$ ng new hello-world
The above command creates a directory with the name hello-world that contains necessary files for an angular application.
Next, navigate into the app you just created above:
$ cd hello-world
Next, run the following command to compile your application.
$ ng serve
By default, the ng serve command runs the application on port 4200. To access your application visit the url http://localhost:4200.
You have successfully compiled and run an angular application.
There is an option to specify the host and port on which to run your application. In this case, I want to run my application on host 0.0.0 and port 8000. Use the command below:
$ ng serve --host 0.0.0.0 --port 8000
You can now develop web Applications using Angular on Ubuntu 22.04.