0
0
Angularframework~10 mins

Angular CLI installation and setup - Step-by-Step Execution

Choose your learning style9 modes available
Concept Flow - Angular CLI installation and setup
Open Terminal
Check Node.js Installed?
NoInstall Node.js
Yes
Run: npm install -g @angular/cli
Verify Angular CLI: ng version
Create Angular Project: ng new my-app
Navigate to Project Folder
Run Development Server: ng serve
Open Browser at localhost:4200
See Angular App Running
This flow shows the steps from opening the terminal to seeing the Angular app running in the browser after installing Angular CLI.
Execution Sample
Angular
npm install -g @angular/cli
ng new my-app
cd my-app
ng serve
Installs Angular CLI globally, creates a new Angular project, moves into the project folder, and starts the development server.
Execution Table
StepCommandActionResultNotes
1npm install -g @angular/cliInstall Angular CLI globallyAngular CLI installedRequires Node.js installed
2ng versionCheck Angular CLI versionShows Angular CLI and environment versionsConfirms successful install
3ng new my-appCreate new Angular projectProject folder 'my-app' created with filesPrompts for routing and style options
4cd my-appChange directory to projectTerminal inside 'my-app' folderReady for commands inside project
5ng serveStart development serverServer running at http://localhost:4200Auto reloads on code changes
6Open browser at localhost:4200View running appDefault Angular welcome page displayedConfirms app is running
7ExitStop server or close terminalDevelopment session endsStop when done working
💡 Execution stops after server is stopped or terminal is closed.
Variable Tracker
VariableStartAfter Step 1After Step 3After Step 5Final
Angular CLINot installedInstalled globallyAvailable to create projectsUsed to run dev serverInstalled and running
Project FolderNoneNone'my-app' created'my-app' active directory'my-app' exists
Dev ServerNot runningNot runningNot runningRunning at localhost:4200Running or stopped
Key Moments - 3 Insights
Why do we need Node.js before installing Angular CLI?
Angular CLI uses Node.js and npm to install and run. Without Node.js, the 'npm install' command will fail (see Step 1 in execution_table).
What happens if you run 'ng serve' outside the project folder?
The command will fail because Angular CLI needs to find the project files in the current directory (see Step 4 and 5 in execution_table).
Why does 'ng new' ask questions during project creation?
It customizes your project setup, like adding routing or choosing CSS style. This happens in Step 3 in execution_table.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table, what command is used to start the Angular development server?
Ang new my-app
Bnpm install -g @angular/cli
Cng serve
Dcd my-app
💡 Hint
Check Step 5 in the execution_table where the server starts.
At which step does the Angular project folder get created?
AStep 3
BStep 2
CStep 4
DStep 5
💡 Hint
Look at the 'Action' column in execution_table for project creation.
If Node.js is not installed, what will happen at Step 1?
AAngular CLI installs successfully
BThe 'npm install' command fails
CProject folder is created anyway
DDevelopment server starts
💡 Hint
Refer to key_moments about Node.js requirement and Step 1 notes.
Concept Snapshot
Angular CLI Installation & Setup:
1. Ensure Node.js is installed.
2. Run 'npm install -g @angular/cli' to install CLI globally.
3. Use 'ng new project-name' to create a new app.
4. Navigate into project folder with 'cd'.
5. Start dev server with 'ng serve' and open browser at localhost:4200.
6. Stop server when done.
Full Transcript
To set up Angular CLI, first open your terminal. Check if Node.js is installed because Angular CLI depends on it. If not, install Node.js. Then run 'npm install -g @angular/cli' to install Angular CLI globally. After installation, verify by running 'ng version'. Next, create a new Angular project using 'ng new my-app'. This command creates a project folder with all necessary files. Change directory into the new project folder using 'cd my-app'. Start the development server with 'ng serve'. This runs the app locally at http://localhost:4200. Open this URL in your browser to see the default Angular welcome page. When finished, stop the server or close the terminal. This process sets up Angular CLI and runs your first Angular app.