Installing Angular on your operating system involves setting up Node.js, the Angular CLI (Command Line Interface), and verifying the installation. Here’s a step-by-step guide for installing Angular on Windows, macOS, and Linux.
1. Prerequisites
Before installing Angular, make sure you have the following:
- Node.js: Angular requires Node.js. You can download it from the official Node.js website.
- npm: Node Package Manager (npm) is installed automatically with Node.js. You can use npm to install Angular CLI.
2. Installing Angular on Windows
Step 1: Install Node.js
- Go to the Node.js download page.
- Download the Windows installer (LTS version recommended).
- Run the installer and follow the installation instructions.
Step 2: Install Angular CLI
- Open Command Prompt (CMD) or PowerShell.
- Type the following command and press Enter:
bash
npm install -g @angular/cli
Step 3: Verify Installation
- Check if Angular CLI is installed by running:
bash
ng --version
- You should see the version information for Angular CLI.
3. Installing Angular on macOS
Step 1: Install Node.js
- Go to the Node.js download page.
- Download the macOS installer (LTS version recommended).
- Open the downloaded file and follow the installation instructions.
Step 2: Install Angular CLI
- Open Terminal.
- Type the following command and press Enter:
bash
npm install -g @angular/cli
Step 3: Verify Installation
- Check if Angular CLI is installed by running:
bash
ng --version
- You should see the version information for Angular CLI.
4. Installing Angular on Linux
Step 1: Install Node.js
- Open Terminal.
- You can use the following commands to install Node.js on Ubuntu-based distributions:
bash
sudo apt update
sudo apt install nodejs npm
- For other Linux distributions, refer to their specific package manager or use NodeSource.
Step 2: Install Angular CLI
- In the terminal, type the following command and press Enter:
bash
sudo npm install -g @angular/cli
Step 3: Verify Installation
- Check if Angular CLI is installed by running:
bash
ng --version
- You should see the version information for Angular CLI.
5. Creating a New Angular Project
After installing Angular CLI, you can create a new Angular project by following these steps:
- Navigate to the folder where you want to create your project:
bash
cd path/to/your/folder
- Create a new Angular project by running:
bash
ng new my-angular-app
Replace
my-angular-app
with your desired project name. - Navigate into your project directory:
bash
cd my-angular-app
- Run the development server:
bash
ng serve
- Open your web browser and navigate to http://localhost:4200/ to see your new Angular application in action.
Conclusion
Installing Angular on Windows, macOS, or Linux is straightforward with Node.js and npm. By following the steps outlined above, you can set up your development environment and start building Angular applications. If you encounter any issues, ensure that Node.js and npm are installed correctly and that your command line or terminal is functioning properly.