Welcome to the second chapter of our Angular guide!
Before writing code, we need to prepare our development environment. Do not worry: we will follow every step together, whether you have a Mac or a Windows PC.
By the end of this chapter, you will have everything you need to develop with Angular professionally: Node.js, Angular CLI, a configured VS Code and Git ready to use.
π What we will install
Here are the tools we need and why they matter:
π’ Node.js: the engine behind everything
Node.js is a runtime environment that runs JavaScript outside the browser. JavaScript normally runs in web pages, but Node.js brings it to your computer, allowing you to:
- Use development tools written in JavaScript (such as Angular CLI).
- Run build and automation scripts.
- Install packages and libraries.
Why do we need it for Angular? Angular CLI (the tool for creating projects) is written in JavaScript and needs Node.js to run. We will also use Node.js for the local development server.
π¦ npm: the package warehouse
npm (Node Package Manager) is the "store" where you can find millions of ready-to-use JavaScript packages. Think of it as the App Store for developers: rather than downloading apps, you download code libraries others have written and shared.
What will we do with npm?
- Install Angular CLI.
- Add libraries to our project (icons, UI components, utilities).
- Manage dependencies automatically.
πΏ Git: a time machine for code
Git is a version control system: it tracks every change to your code over time.
What can you do with Git?
- Save snapshots of your project.
- Go back to earlier versions if something breaks.
- Work in a team without overwriting other people's work.
- Experiment with features in separate branches.
π The other tools
- Angular CLI: the official tool for creating and managing Angular projects.
- VS Code: the code editor (with the right extensions).
π Installation on macOS
1. Install Node.js on macOS
Option A: direct download (recommended for beginners)
- Visit nodejs.org.
- Download the LTS (Long Term Support) version, the recommended option.
- Open the downloaded
.pkgfile and follow the installation wizard. - Restart the terminal.
Option B: Homebrew (if you already use it)
1# Install Homebrew if needed
2/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
3
4# Install Node.js
5brew install nodeTo check the installation, open the terminal and type:
node --version
npm --versionYou should see something like:
v20.15.0
10.7.02. Install Angular CLI on macOS
In the terminal, run:
npm install -g @angular/cliThe -g flag installs Angular CLI globally, so you can use it from any folder.
Check the installation:
ng versionYou should see Angular CLI version information.
3. Install VS Code
- Visit code.visualstudio.com.
- Download the macOS version.
- Open the
.zipfile and drag the app into Applications. - Launch VS Code.
4. Install Git
Option A: direct download
- Visit git-scm.com.
- Download the macOS version.
- Follow the installation wizard.
Option B: Homebrew
brew install gitCheck the installation:
git --versionπͺ Installation on Windows
1. Install Node.js on Windows
- Visit nodejs.org.
- Download the LTS version for Windows.
- Run the
.msifile and follow the installation wizard. - β Important: make sure "Add to PATH" is selected during installation.
To check the installation, open Command Prompt (cmd) or PowerShell and type:
node --version
npm --version2. Install Angular CLI on Windows
In Command Prompt:
npm install -g @angular/cliPossible Windows issues If you get permission errors, try:
# Open PowerShell as administrator
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
npm install -g @angular/cliCheck the installation:
ng version