Create new angular project
Here are the steps to create a new Angular project:
Using the Angular CLI
- Open a terminal or command prompt.
- Install the Angular CLI by running the following command:
npm install -g @angular/cli
(oryarn global add @angular/cli
if you're using Yarn). - Create a new Angular project by running the following command:
ng new my-app
(replacemy-app
with your desired project name). - Follow the prompts to choose the project template and configuration options.
- Once the project is created, navigate to the project directory by running
cd my-app
. - Run
ng serve
to start the development server and open the project in your default web browser.
Using the Angular CLI with a specific version
If you want to create a new Angular project with a specific version of Angular, you can specify the version when running the ng new
command. For example:
ng new my-app --version 12.2.0
This will create a new Angular project using Angular 12.2.0.
Using a code editor or IDE
If you prefer to create a new Angular project using a code editor or IDE, you can follow these steps:
- Open your code editor or IDE (e.g. Visual Studio Code, IntelliJ IDEA, etc.).
- Create a new project by selecting the "Angular" template or choosing the "Blank" template and then installing the Angular CLI.
- Name your project and choose the project location.
- Follow the prompts to choose the project template and configuration options.
- Once the project is created, navigate to the project directory and run
ng serve
to start the development server and open the project in your default web browser.
Here's an example of how to create a new Angular project using Visual Studio Code:
- Open Visual Studio Code.
- Click on "File" > "New Folder" and name your project (e.g. "my-app").
- Open the terminal by clicking on "Terminal" > "New Terminal" or pressing
Ctrl + Shift +
(backtick). - Run the following command:
ng new my-app
(replacemy-app
with your desired project name). - Follow the prompts to choose the project template and configuration options.
- Once the project is created, navigate to the project directory by running
cd my-app
. - Run
ng serve
to start the development server and open the project in your default web browser.