Security News
JSR Working Group Kicks Off with Ambitious Roadmap and Plans for Open Governance
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
@angular/cli
Advanced tools
The @angular/cli package is a command-line interface tool that you can use to initialize, develop, scaffold, and maintain Angular applications directly from a command shell. It provides commands for creating new projects, generating application and library code, performing a variety of ongoing development tasks such as testing, bundling, and deployment.
Project Scaffolding
Creates a new Angular application with a default structure by running the 'ng new' command followed by the project name.
ng new my-angular-app
Generating Components, Services, and other features
Generates a new component and its associated files by using the 'ng generate' command followed by the feature type and name.
ng generate component my-component
Building and Serving the Application
Compiles the application and starts a web server, making the app accessible in a browser. The 'ng serve' command is used for this purpose.
ng serve
Running Unit Tests
Executes the unit tests defined in the application using the 'ng test' command.
ng test
Building for Production
Compiles the application for production deployment, optimizing the build for performance and size using the 'ng build' command with the '--prod' flag.
ng build --prod
Similar to @angular/cli, create-react-app is a command-line interface for setting up new React applications. It abstracts away build configuration to a pre-configured setup, allowing developers to focus on writing code. Unlike @angular/cli, it is tailored specifically for React and does not provide an extensive set of generation commands.
Vue CLI is a full system for rapid Vue.js development, similar to @angular/cli for Angular. It provides project scaffolding, a development server, build tools, and a set of plugins for common tasks. Vue CLI is designed for Vue.js and offers a similar level of functionality for Vue developers.
Ember CLI is a command-line utility for creating, developing, and building Ember.js applications. It provides a standardized development structure and build pipeline, much like @angular/cli does for Angular. Ember CLI focuses on Ember.js and has a strong emphasis on convention over configuration.
CLI for Angular applications based on the ember-cli project.
The CLI is now in 1.0. If you are updating from a beta or RC version, check out our [1.0 Update Guide] (https://github.com/angular/angular-cli/wiki/stories-1.0-update).
If you wish to collaborate, check out our issue list.
Before submitting new issues, have a look at issues marked with the type: faq
label.
Both the CLI and generated project have dependencies that require Node 6.9.0 or higher, together with NPM 3 or higher.
BEFORE YOU INSTALL: please read the prerequisites
npm install -g @angular/cli
ng help
ng new PROJECT_NAME
cd PROJECT_NAME
ng serve
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 :
ng serve --host 0.0.0.0 --port 4201
You can use the ng generate
(or just ng g
) command to generate Angular components:
ng generate component my-new-component
ng g component my-new-component # using the alias
# components support relative path generation
# if in the directory src/app/feature/ and you run
ng g component new-cmp
# your component will be generated in src/app/feature/new-cmp
# but if you were to run
ng g component ../newer-cmp
# your component will be generated in src/app/newer-cmp
You can find all possible blueprints in the table below:
Scaffold | Usage |
---|---|
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 |
If you're using Angular CLI beta.28
or less, you need to uninstall angular-cli
package. It should be done due to changing of package's name and scope from angular-cli
to @angular/cli
:
npm uninstall -g angular-cli
npm uninstall --save-dev angular-cli
To update Angular CLI to a new version, you must update both the global package and your project's local package.
Global package:
npm uninstall -g @angular/cli
npm cache clean
npm install -g @angular/cli@latest
Local project package:
rm -rf node_modules dist # use rmdir /S/Q node_modules dist in Windows Command Prompt; use rm -r -fo node_modules,dist in Windows PowerShell
npm install --save-dev @angular/cli@latest
npm install
You can find more details about changes between versions in CHANGELOG.md.
git clone https://github.com/angular/angular-cli.git
cd angular-cli
npm link
npm link
is very similar to npm install -g
except that instead of downloading the package
from the repo, the just cloned angular-cli/
folder becomes the global package.
Any changes to the files in the angular-cli/
folder will immediately affect the global @angular/cli
package,
allowing you to quickly test any changes you make to the cli project.
Now you can use @angular/cli
via the command line:
ng new foo
cd foo
npm link @angular/cli
ng serve
npm link @angular/cli
is needed because by default the globally installed @angular/cli
just loads
the local @angular/cli
from the project which was fetched remotely from npm.
npm link @angular/cli
symlinks the global @angular/cli
package to the local @angular/cli
package.
Now the angular-cli
you cloned before is in three places:
The folder you cloned it into, npm's folder where it stores global packages and the Angular CLI project you just created.
You can also use ng new foo --link-cli
to automatically link the @angular/cli
package.
Please read the official npm-link documentation and the npm-link cheatsheet for more information.
The documentation for the Angular CLI is located in this repo's wiki.
MIT
FAQs
CLI tool for Angular
The npm package @angular/cli receives a total of 2,212,726 weekly downloads. As such, @angular/cli popularity was classified as popular.
We found that @angular/cli demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
Security News
Research
An advanced npm supply chain attack is leveraging Ethereum smart contracts for decentralized, persistent malware control, evading traditional defenses.
Security News
Research
Attackers are impersonating Sindre Sorhus on npm with a fake 'chalk-node' package containing a malicious backdoor to compromise developers' projects.