Angular Setup Environment
To setup Angular to run on our local machine, we need to have NodeJS installed on our machine. We must also ensure that our development environment includes Node.js and an npm package manager.
Node.js
Angular requires Node.js version 8.x or 10.x.
To check your version, run node -v in a terminal/console window.
To get Node.js, go to nodejs.org.
npm (Node 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.
This Quick Start uses the npm client command line interface, which is installed with Node.js by default.
To check that you have the npm client installed, run npm -v in a terminal/console window
Install the Angular CLI
Angular CLI is used to create angular projects, generate application and library code, and perform a variety of ongoing development tasks such as testing, bundling, and deployment. The Angular CLI can be installed either locally or globally. But it is often recommended to install it globally, thus to install Angular CLI globally using npm, open a terminal/console window and enter the following command:
Create a workspace and initial application
You develop apps in the context of an Angular workspace. A workspace contains the files for one or more projects. A project is the set of files that comprise an app, a library, or end-to-end (e2e) tests.
To create a new workspace and initial app project:
Run the CLI command ng new and provide the name my-app, as shown here:
The `ng new` command prompts you for information about features to include in the initial app project. Since this is our first application, accept defaults by pressing Enter/Return all through the prompts.
The Angular CLI installs the necessary Angular npm packages and other dependencies. This can take a few minutes, depending on your internet connection.
It also creates the following workspace and starter project files:
- A new workspace, with a root folder named my-app
- An initial skeleton app project also called my-app (in the src subfolder)
- An end-to-end test project (in the e2e subfolder)
- Related configuration files
The initial app project contains a simple welcome application, ready to run.
Serve the application
Angular includes a server, so that you can easily build and serve your app locally by going to the workspace folder (my-app). Launch the server by using the CLI command ng serve, with the --open option.
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. The Angular application uses port 4200 by default.
Thank You !!!
Comments
Post a Comment