ng
Generate, build, serve, and test Angular applications
TLDR
Create a new Angular application inside a directory
Add a new component to one's application
Add a new class to one's application
Add a new directive to one's application
Run the application with the following command in its root directory
Build the application
Run unit tests
Display the version of your current Angular installation
SYNOPSIS
ng <command> [options]
ng <collection>:<schematic> [options]
Examples:
ng new my-app
ng serve --open
ng generate component user-profile
ng build --prod
PARAMETERS
new
Creates a new Angular workspace and application with a specified project name.
generate (or g)
Generates and/or modifies files based on an Angular schematic (e.g., component, service, module).
serve
Builds and serves the application, rebuilding on file changes, typically for development.
build
Compiles an Angular application into an output directory for deployment.
test
Runs unit tests configured for the project.
e2e
Runs end-to-end tests for the application.
add
Adds support for an external library to your project.
update
Updates your application and its dependencies, including the Angular framework itself.
deploy
Invokes a builder to deploy your application to a specified target.
lint
Runs linting tools on your application code to enforce coding standards.
config
Manipulates Angular configuration values within the workspace or project.
version
Outputs the Angular CLI version and relevant details like Node.js and OS versions.
help
Displays help for a given command or the top-level commands.
DESCRIPTION
The ng command is the fundamental interface for the Angular CLI (Command Line Interface), a powerful tool for developing Angular applications. While ng runs on Linux, it is crucial to understand that it is not a native Linux utility but a Node.js application installed via npm (Node Package Manager). Its primary purpose is to streamline the development workflow by automating common tasks, from project creation to deployment. Developers use ng to scaffold new projects, generate application components, services, and modules, run development servers, build applications for production, execute tests, and manage project dependencies and configurations. It enforces best practices and ensures consistency across Angular projects, significantly enhancing developer productivity and efficiency within the Angular ecosystem.
CAVEATS
ng is not a pre-installed or native Linux command; it requires Node.js and npm to be installed globally on your system. Its functionality is entirely dependent on the Angular ecosystem, making it distinct from traditional shell commands. Each subcommand of ng has its own extensive set of options, which can be explored using ng <command> --help.
CONTEXT
The command 'ng' primarily refers to the Angular CLI (Command Line Interface), a powerful set of tools used for developing and managing applications built with the Angular framework. It is not a standard, pre-installed Linux operating system command but rather a JavaScript application executed via Node.js.
SUBCOMMAND STRUCTURE
The ng command typically operates using a subcommand structure (e.g., ng <command>). Many commands also have aliases (e.g., ng generate can be shortened to ng g). Options are then appended to the subcommand, allowing for fine-grained control over its behavior.
HISTORY
The ng command, as part of the Angular CLI, was first introduced to simplify the development process of Angular applications. It gained prominence with Angular 2+ as a crucial tool to manage the complexity of modern front-end development, including TypeScript compilation, module bundling, and dependency management. Its evolution has closely mirrored the development of the Angular framework itself, with continuous updates introducing new features, improving performance, and adapting to changes in web development best practices.