Swiftorial Logo
Home
Swift Lessons
Matchups
CodeSnaps
Tutorials
Career
Resources

Setting Up the Development Environment for Angular

To start developing Angular applications, you need to set up a development environment on your machine. This tutorial guides you through the steps to install the necessary tools and create your first Angular project.

Prerequisites

Before you begin, ensure that you have the following installed on your machine:

  • Node.js: Angular requires Node.js for building and running applications. You can download and install the latest version of Node.js from the official website.
  • npm: npm (Node Package Manager) is included with Node.js and is used to install Angular CLI and other dependencies.
  • Code Editor: A code editor such as Visual Studio Code, WebStorm, or Sublime Text. Visual Studio Code is recommended for its Angular-specific extensions and features.

Step 1: Install Angular CLI

The Angular CLI (Command Line Interface) is a powerful tool that helps you create, build, and manage Angular applications. To install Angular CLI, open your terminal or command prompt and run the following command:

npm install -g @angular/cli

This command installs Angular CLI globally on your machine, allowing you to use it from any directory.

Step 2: Create a New Angular Project

Once Angular CLI is installed, you can create a new Angular project using the following command:

ng new my-angular-app

Replace my-angular-app with your desired project name. Angular CLI will prompt you to select some configuration options, such as including Angular routing and choosing the stylesheet format (CSS, SCSS, etc.). Select your preferences and Angular CLI will generate a new Angular project with the specified configuration.

Step 3: Navigate to Your Project Directory

After creating the new project, navigate to the project directory using the following command:

cd my-angular-app

Step 4: Serve the Application

To run your Angular application locally, use the following command:

ng serve

Angular CLI will build the application and start a development server. By default, the application will be accessible at http://localhost:4200. Open this URL in your web browser to see your running Angular application.

Step 5: Open the Project in Your Code Editor

Open your project directory in your preferred code editor. If you are using Visual Studio Code, you can open the project using the following command:

code .

This command opens the current directory in Visual Studio Code. You can now start developing your Angular application by modifying the files in the src directory.

Conclusion

By following these steps, you have set up your development environment for Angular and created a new Angular project. You can now start building your Angular applications by leveraging the powerful features and tools provided by the Angular framework and CLI. Happy coding!