What is Angular CLI?
Angular is a tool for building web apps. The CLI (command line interface) is a program you control by typing commands. With it you can create and run Angular projects quickly.
Angular CLI needs Node.js. Node.js lets you run JavaScript outside a web browser. It also brings npm, a tool that downloads add-ons.
Steps
- Log in to your server over SSH as root.
- Update your packages.
yum update -y
This downloads the newest fixes for installed software.
- Add the Node.js source. The number 18 is an example. Pick a version that your system supports.
curl -fsSL https://rpm.nodesource.com/setup_18.x | bash -
This tells your system where to download Node.js from.
- Install Node.js.
yum install -y nodejs
This installs Node.js and npm.
- Check both are installed.
node -v
npm -v
Each command prints a version number.
- Install Angular CLI for the whole server.
npm install -g @angular/cli
The -g flag means global. Any user on the server can then use the ng command.
- Confirm the install.
ng version
You should see the Angular CLI version and your Node.js version.
Create a test project
- Go to a folder where you keep projects.
- Run
ng new my-app. - Answer the questions. The default answers are fine.
- Go into the folder with
cd my-app. - Start it with
ng serve --host 0.0.0.0.
Your app now runs on port 4200. You may need to open that port in your firewall.
Common problems
- Command not found: Close and reopen your SSH session.
- Node version too old: Angular needs a fairly new Node.js. Install a newer one from NodeSource.
- Not enough memory: Small servers can fail while building. Ask Hostvento support about your server size.
Quick recap
- You need root access and SSH.
- Install Node.js first, then Angular CLI with npm.
- Use
ng versionto check the install. - Create a test app with
ng new.