NashTech Insights

Setting Up Your Angular Environment

Alka Vats
Alka Vats
Table of Contents

Introduction

Angular is a powerful and popular front-end framework developed and maintained by Google. Setting up your Angular environment is the first step to start building modern web applications with ease. In this blog, we will walk you through the process of setting up your Angular environment, including the installation of Node.js, Angular CLI, and the creation of a new Angular project. Let’s get started!

If you want to learn about the NGRX, state management angular, you can refer here.

Step 1: Install Node.js

Before setting up Angular, you need to have Node.js installed on your system. Node.js is a JavaScript runtime that allows you to run JavaScript code outside of a web browser. Angular CLI, which we will install later, depends on Node.js to function correctly.

To install Node.js, follow these steps:
  1. Visit the Node.js website at https://nodejs.org.
  2. Download the recommended LTS version for your operating system (Windows, macOS, or Linux).
  3. Run the installer and follow the installation prompts.

To verify that Node.js is installed correctly, open your terminal (or command prompt) and type the following command:

node -v

You should see the version number of Node.js displayed if the installation was successful.

Step 2: Install Angular CLI

Angular CLI (Command Line Interface) is a powerful tool that simplifies various tasks when working with Angular projects. It allows you to generate components, services, modules, and more with just a few commands.

To install Angular CLI, open your terminal (or command prompt) and run the following command:

npm install -g @angular/cli

The -g flag ensures that Angular CLI is installed globally on your system, making it accessible from any directory.

To verify that Angular CLI is installed correctly, run the following command:

ng version

You should see the version number of Angular CLI displayed, along with the versions of Angular packages installed.

Step 3: Create a New Angular Project

With Angular CLI installed, you can now create a new Angular project with ease. To create a new project, follow these steps:

1. Open your terminal (or command prompt).

2. Navigate to the directory where you want to create your Angular project. For example, if you want to create the project in a folder named my-angular-app, use the cd command to move into that directory:

cd path/to/my-angular-app

3. Once you are in the desired directory, run the following command to create a new Angular project:

ng new my-angular-app

Replace my-angular-app with the desired name for your project. This command will prompt you to select various configuration options for your project, such as whether to include Angular routing or which stylesheet format to use (CSS, SCSS, etc.).

4. After the project is created, navigate to the project folder using the cd command:

cd my-angular-app

Step 4: Serve Your Angular Application

Now that you have created your Angular project, you can serve it locally to see your application in action. The Angular CLI comes with a development server that allows you to run your application locally during development.

To serve your Angular application, run the following command:

ng serve

After the server is up and running, you should see a message indicating that your app is running at http://localhost:4200/.

Open your web browser and navigate to http://localhost:4200/. You should see the default Angular application homepage, indicating that your project is running successfully.

Step 5: Explore Your Angular Project Structure

Congratulations! You have successfully set up your Angular environment and created a new Angular project. Now, let’s briefly explore the structure of your newly created Angular project:

  • src: This folder contains the source code for your Angular application, including the main index.html file, app folder, and other assets and configuration files.
  • src/app: The app folder contains the main components and modules for your application.
  • src/app/app.component: The root component of your application, defined in app.component.ts.
  • angular.json: This file contains configuration settings for your Angular project.
  • package.json: This file lists the dependencies and scripts required for your project.

Conclusion

Setting up your Angular environment is the first step to building powerful and feature-rich web applications. By following this step-by-step guide, you have installed Node.js, and Angular CLI, created a new Angular project, and explored the project structure.

With your Angular environment ready, you can now dive deeper into Angular development, create components, and services, and implement various features to build cutting-edge web applications.

Finally, for more such posts, please follow our LinkedIn page- FrontEnd Competency.

Alka Vats

Alka Vats

Alka Vats is a Software Consultant at Nashtech. She is passionate about web development. She is recognized as a good team player, a dedicated and responsible professional, and a technology enthusiast. She is a quick learner & curious to learn new technologies. Her hobbies include reading books, watching movies, and traveling.

Leave a Comment

Your email address will not be published. Required fields are marked *

Suggested Article

%d bloggers like this: