How to set up the local environment and workspace for Angular development?
May 9, 2020

In this article, I'm going to show you how to set up your environment for Angular development using the command-line interface.

If you want to get the grasp of Angular then you should know the following:

1. JavaScript


3. CSS

If you know Typescript, it's better to understand some concept but it's not required. 

Let's set up the environment by installing the components one by one.


Requirement 1: Node.js

Make sure your development environment includes Node.js and an npm package manager.

Angular requires a current, active LTS, or maintenance LTS version of Node.js. 

To check your version, run node -v in a terminal/console window.

To get Node.js, go to nodejs.org.

Requirement 2: npm package manager

Angular, the Angular CLI, and Angular apps depend on features and functionality provided by libraries that are available as npm packages.

To download and install npm packages, you must have an npm package manager. npm client command line interface is installed with Node.js by default.

To check that you have the npm client installed, run npm -v in a terminal/console window.

One you have those 2 required components, then you can go ahead and start with step 1 of installation.


Step 1: Install the Angular CLI

We use the Angular CLI to create projects, generate application and library code, and perform a variety of ongoing development tasks such as testing, bundling, and deployment.

We need to install the Angular CLI globally.

To install the CLI using npm, open a terminal/console window and enter the following command:

npm install -g @angular/cli

Step 2: Create a workspace and initial application

We develop apps in the context of a workspace, which is called Angular workspace.

To create a new workspace and initial starter app:

1. Run the CLI command ng new and provide the name my-app, as shown here:

ng new my-app

//you can use any name you want

2. The ng new command might ask you for information about features to include in the initial app. You can just accept the default options as per now. To do that, just press the return key (MAC users) or enter key (Windows/Linux users).

The Angular CLI installs the necessary Angular npm packages and other dependencies. This can take a few minutes. Probably 5-10 minutes.

The CLI creates a new workspace and a simple Welcome app, ready to run.

Step 3: Run the application

The Angular CLI includes a server, so that you can easily build and serve your app locally.

1. Go to the workspace folder (my-app).

When you run this command, the CLI installs the necessary Angular npm packages and other dependencies in a new workspace, with a root-level application named my-project. The workspace root folder contains various support and configuration files, and a README file with generated descriptive text that you can customize.

If you're not sure where your project folder is located. Just go to your C drive (Windows users) and you'll see the folder named my-app.

For MAC users, it's located inside your admin user's root directory.

2. Launch the server by using the CLI command ng serve, with the –open option.

cd my-app
ng serve --open

The ng serve command launches the server, watches your files, and rebuilds the app as you make changes to those files.

The –open (or just -o) option automatically opens your browser to http://localhost:4200/.

You will see this window open automatically. (It doesn't have to be a guest window.)

Angular local dev environment
Angular local dev environment

Credit: Angular.io


Leave a Reply

Most Read

#1 How to check if radio button is checked or not using JavaScript? #2 How to set opacity or transparency using CSS? #3 Pagination in CSS with multiple examples #4 How to make HTML form interactive and using CSS? #5 Solution to “TypeError: ‘x’ is not iterable” in Angular 9 #6 How to uninstall Cocoapods from the Mac OS?

Recently Posted

Mar 5 How to create flickering text using CSS? Mar 4 How to use data-* Attributes in HTML? Mar 4 The substr() method in JavaScript and how it’s different from substring() Mar 4 A complete guide to add responsive YouTube videos using HTML and CSS Mar 3 How to embed YouTube or other video links in WordPress? Mar 3 How to change the Login Logo in WordPress?

You might also like these

How to get ACF values from custom post type?WordPressWhat is Object Mutability in JavaScript?JavaScriptWhat is Hadoop and Hadoop Ecosystem?MiscCommon Table Expressions (CTE) in PostgreSQLPostgresThe SELECT DISTINCT Statement in SQLSQL/MySQLHow to Make CSS Lists Bullets Smaller?CSS