Before you start building Angular applications, you must set up the development environment. Angular requires Node.js, npm (Node Package Manager), and the Angular CLI. The overall setup steps are almost the same for both Windows and macOS.
First, you install Node.js (which automatically installs npm), then you install the Angular CLI globally, and finally you create and run your first Angular project.
? Step 1: Install Node.js & npm ?️ Step 2: Install Angular CLI ? Step 3: Create & Run Project
-g so it is available in any folder.http://localhost:4200.Angular provides a command-line tool called Angular CLI that simplifies project setup and development. Some important commands:
npm install -g @angular/cli – Installs Angular CLI globally.ng new <project-name> – Creates a new Angular project.cd <project-name> – Moves into the project folder.ng serve – Starts the local development server.Using the CLI ensures that your project follows Angular’s recommended structure and includes all necessary configuration files from the beginning.
Download and install the LTS (Long Term Support) version of Node.js from the official website. The installer will also install npm automatically:
After installation, verify that Node.js and npm are installed correctly using the terminal or command prompt:
# Verify Node.js and npm installation
node -v
npm -v
Once Node.js and npm are installed, install the Angular CLI globally using npm. This makes the ng command available from anywhere on your system:
# Install Angular CLI globally using npm
npm install -g @angular/cli
On macOS or Linux, if you face permission issues, you can run the command with sudo (you will be asked for your system password).
After installing the Angular CLI, you can create a new Angular project and run it on the development server:
# Create a new Angular project and start the dev server
ng new my-app
cd my-app
ng serve
When you run ng new my-app, Angular CLI:
my-app.package.json.After moving into the project using cd my-app and running ng serve, Angular compiles the project and starts a development server. You can open your browser and navigate to:
? URL: http://localhost:4200
You should now see the default Angular welcome page. Any changes you make in the source files will automatically reload in the browser.
npm update -g @angular/cli.sudo npm install -g @angular/cli.node, npm, and ng are recognized in any folder.ng serve inside the Angular project folder (for example, inside my-app), not from a parent directory.ng version.hello-angular and run it locally using ng serve.ng generate component test and observe the files it creates.src folder and identify where the root component is defined.