This lesson guide for establishing a development environment of Angular for the best learning and working experience.
To work with Angular (any version), you will need to install a few applications on your computer:
- Setup a Node.js development environment with npm (node package manager)
- Setup the Angular CLI (command-line interface)
- Setup an Editor/IDE
The Reason Why Angular Needs node.js
Node.js is a server-side backend, which makes it important but not mandatory for AngularJS. However, you will need node.js for the following purposes:
- npm is a package manager that comes with node.js by default; it allows you to manage your project dependencies. Therefore, you do not have to worry about manually adding dependencies, removing some, and updating your package. Most Angular libraries are assigned as different NPM packages.
- npm provides the Angular CLI (command-line interface), a great tool to build Angular applications efficiently.
- Angular works on the client-side, while on the server-side, you will need a node.js server environment for processing.
node.js Development Environment Setup
To get the best development experience, and if you do not yet have the node pre-installed on your System: Please go to the download page of the nodej.org website and install the latest version of the node.
To check whether 'Node.js' is already installed in your system, you need to type the node -v command in your terminal prompt. This will immediately show you the Node.js version installed on your system. Furthermore, to check the Node Package Manager, you can use the npm -v command in your terminal prompt.
What is Angular CLI?
The Angular CLI (command-line interface) is a great tool to efficiently build Angular application by automating operations in Angular projects rather than manually.
Angular CLI (command-line interface) Setup
If you have installed node.js on your system, the next step is to install Angular CLI by using the following command:
npm install -g @angular/cli
Here in the above command, -g is used for global installation. If you write this, you can use the CLI directly in any Angular project on your system.
ng version or
v command at your terminal prompt to verify your angular
Create a New Angular Project
After installing Angular CLI, you can now use it to create a new Angular project using the following command:
ng new my-app
The above command creates a new angular project(my-app) with all the required dependencies.