Angular CLI
Missing command line interface documentation for Angular.
The official documentation for the Angular CLI is located in this repo's wiki.
What Is Angular CLI?
Angular CLI is a command-line interface (CLI) to automate your development workflow. It allows you to:
create a new Angular application
run a development server with LiveReload support to preview your application during development
add features to your existing Angular application
run your application’s unit tests
run your application’s end-to-end (E2E) tests
build your application for deployment to production.
Prerequisites
Both the CLI and generated project have dependencies that require Node 8.9
or higher, together with NPM 5.5.1
or higher.
You can download the latest version of Node.js for your operating system and consult the latest installation instructions on the official Node.js website.
If you already have Node.js and npm installed, you can verify their version by running:
Getting Started
To install the Angular CLI:
or
Then make sure that it’s installed on your system and prints out version 6.0 or greater.
Usage
Generating and serving an Angular project via a development server. Create and run a new project:
Navigate to http://localhost:4200/. The app will automatically reload if you change any of the source files.
You can configure the default HTTP host and port used by the development server with two command-line options :
Generating
You can use the ng generate
(or just ng g
) command to generate Angular components, directives, pipes, services and more.
You can find all possible blueprints in the table below:
Scaffold
Usage
ng g application my-new-app
Component
ng g component my-new-component
Directive
ng g directive my-new-directive
Pipe
ng g pipe my-new-pipe
Service
ng g service my-new-service
Class
ng g class my-new-class
Guard
ng g guard my-new-guard
Interface
ng g interface my-new-interface
Enum
ng g enum my-new-enum
Module
ng g module my-module
angular-cli will add reference to components
, directives
and pipes
automatically in the app.module.ts
. If you need to add this references to another custom module, follow these steps:
ng g module new-module
to create a new modulecall
ng g component new-module/new-component
This should add the new component
, directive
or pipe
reference to the new-module
you've created.
Updating
To update Angular CLI to a new version, you must update both the global package and your project's local package.
Global package:
If npm version is < 5 then use npm cache clean
Local project package:
Use rmdir /S/Q node_modules dist in Windows Command Prompt; use rm -r -fo node_modules,dist in Windows PowerShell
You can find more details about changes between versions in the Releases tab on GitHub.
Last updated