Guides 11792 Published by

This guide walks readers through getting AngularJS onto AlmaLinux 9 by installing Node 18 via the system’s module stream, adding a project folder, optionally initializing npm, and then pulling in the lightweight 1.x library with `npm install angular`. It also shows how to create a simple `index.html` that loads AngularJS either from a CDN or local `node_modules`, defines a minimal controller, and demonstrates real‑time binding with an input field. To test the setup locally, the tutorial recommends starting a quick HTTP server using Python or Node’s `http-server`, noting that serving via file:// can trigger CORS errors while a web server avoids those pitfalls. Finally, it highlights common mistakes such as using an incompatible Node version, mixing Angular 2+ syntax with 1.x, and omitting the npm initialization step, all while keeping the instructions clear and free of heavy tooling requirements.



Installing AngularJS on AlmaLinux 9 – Quick Start Guide

If you’re running AlmaLinux 9 and want a lightweight MVC framework for a quick prototype, AngularJS is still a solid choice. This walk‑through shows how to get the library up and running with Node, npm, or even just a CDN link, so you can start building right away.

Prerequisites – Make Sure You Have Root or Sudo

AlmaLinux 9 uses `dnf` for package management. Unless you’re already in an admin shell, you’ll need to prefix commands with `sudo`.

If your user isn’t part of the `wheel` group, add yourself first:

sudo usermod -aG wheel <your‑user>

You’ll only have to do this once.

Step 1 – Install Node.js and npm

AngularJS can be pulled in via npm for project‑local usage, or you can just grab a CDN if you’re writing a small demo.

The official AlmaLinux repositories ship Node 18.x, which is plenty more than enough for AngularJS.

sudo dnf module install nodejs:18

Why the `module` command? AlmaLinux uses Application Streams; this guarantees you get the correct Node version without clashing with future releases.

Verify:

node --version   # should show 18.x
npm --version    # npm comes bundled

If you prefer a newer Node, install from NodeSource instead.

Step 2 – Create a Fresh Project Folder
mkdir angularjs-demo && cd angularjs-demo

Why start clean? AngularJS isn’t opinionated about folder structure, but having a dedicated workspace keeps npm packages and your source files tidy.

Step 3 – Initialize npm (Optional)

If you plan to bundle the library or add other dependencies:

npm init -y

This creates a `package.json` so future installs are reproducible.

Real‑world note: I’ve seen people run into “Cannot find module” errors when they forget this step and then try to import AngularJS later on.

Step 4 – Install AngularJS via npm (Project‑Local)
npm install angular

This pulls in the latest stable AngularJS release (`angular@1.8.x`).

The package is tiny, so it won’t bloat your node_modules directory.

Why bother with npm instead of a CDN? When you bundle, you can use tools like Rollup or Browserify to strip out unused code and keep file sizes low. For quick experiments, a CDN is fine.

Step 5 – Set Up the HTML Skeleton

Create `index.html`:

<!DOCTYPE html>
<html ng-app="demoApp">
<head>
  <meta charset="utf-8" />
  <title>AngularJS Demo on AlmaLinux</title>
  <!-- CDN is simplest for prototyping -->
  <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.8.2/angular.min.js"></script>
</head>
<body ng-controller="DemoCtrl">
  <h1>{{ greeting }}</h1>
  <input type="text" ng-model="greeting" placeholder="Type something…" />
</body>
<script>
  angular.module('demoApp', [])
    .controller('DemoCtrl', function($scope) {
      $scope.greeting = 'Hello, AlmaLinux!';
    });
</script>
</html>

Why include the script via CDN first? It bypasses npm’s node_modules path and ensures you’re always running a known good build. If you prefer local, swap the `<script>` tag with `src="https://www.linuxcompatible.org/node_modules/angular/angular.min.js"`.

Step 6 – Run a Local Server (Optional but Handy)

AlmaLinux doesn’t ship a default web server for dev purposes. Install a tiny Python HTTP server:

python3 -m http.server 8000

Open `http://localhost:8000` in your browser, and you should see the greeting box update as you type.

If you’re comfortable with Node, try:

npx http-server .

Either way, this mimics what a real web host would do.

Common Pitfalls & How to Avoid Them

Wrong Node version
AngularJS works fine on Node 18, but if you accidentally install the latest LTS (Node 20) and run `npm audit`, you might see warnings about deprecated packages. Stick with the module install above.

CORS issues when using a local file
Opening `index.html` directly from the filesystem can trigger cross‑origin errors in some browsers. Always serve via an HTTP server.

Using Angular (2+) syntax with AngularJS
Remember, this is 1.x. Controllers, `$scope`, and the `ng-app` directive are your bread and butter. Mixing them up leads to hard‑to‑debug runtime errors.

Wrap‑Up

That’s all you need to get AngularJS running on AlmaLinux 9. Whether you pull it from npm for a small project or drop in the CDN for a quick demo, the steps are straightforward and don’t require fancy tooling. Happy coding!