{ "id": "guide/setup-local", "title": "Setting up the local environment and workspace", "contents": "\n\n\n
This guide explains how to set up your environment for Angular development using the Angular CLI tool.\nIt includes information about prerequisites, installing the CLI, creating an initial workspace and starter app, and running that app locally to verify your setup.
\nIf you are new to Angular, you might want to start with Try it now!, which introduces the essentials of Angular in the context of a ready-made basic online store app that you can examine and modify. This standalone tutorial takes advantage of the interactive StackBlitz environment for online development. You don't need to set up your local environment until you're ready.
\nTo use the Angular framework, you should be familiar with the following:
\nKnowledge of TypeScript is helpful, but not required.
\nTo install Angular on your local system, you need the following:
\n\nNode.js
\nAngular requires a current, active LTS, or maintenance LTS version of Node.js.
\nFor information about specific version requirements, see the engines
key in the package.json file.
For more information on installing Node.js, see nodejs.org.\nIf you are unsure what version of Node.js runs on your system, run node -v
in a terminal window.
npm package manager
\nAngular, the Angular CLI, and Angular applications depend on npm packages for many features and functions.\nTo download and install npm packages, you need an npm package manager.\nThis guide uses the npm client command line interface, which is installed with Node.js
by default.\nTo check that you have the npm client installed, run npm -v
in a terminal window.
You 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.
\nTo install the Angular CLI, open a terminal window and run the following command:
\nYou develop apps in the context of an Angular workspace.
\nTo create a new workspace and initial starter app:
\nRun 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. Accept the defaults by pressing the Enter or Return key.
The Angular CLI installs the necessary Angular npm packages and other dependencies. This can take a few minutes.
\nThe CLI creates a new workspace and a simple Welcome app, ready to run.
\nYou also have the option to use Angular's strict mode, which can help you write better, more maintainable code.\nFor more information, see Strict mode.
\nThe Angular CLI includes a server, so that you can build and serve your app locally.
\nNavigate to the workspace folder, such as my-app
.
Run the following command:
\nThe ng serve
command launches the server, watches your files,\nand rebuilds the app as you make changes to those files.
The --open
(or just -o
) option automatically opens your browser\nto http://localhost:4200/
.
If your installation and setup was successful, you should see a page similar to the following.
\nFor a more thorough introduction to the fundamental concepts and terminology of Angular single-page app architecture and design principles, read the Angular Concepts section.
\nWork through the Tour of Heroes Tutorial, a complete hands-on exercise that introduces you to the app development process using the Angular CLI and walks through important subsystems.
\nTo learn more about using the Angular CLI, see the CLI Overview. In addition to creating the initial workspace and app scaffolding, you can use the CLI to generate Angular code such as components and services. The CLI supports the full development cycle, including building, testing, bundling, and deployment.
\nFor more information about the Angular files generated by ng new
, see Workspace and Project File Structure.