Questions tagged [angular-cli]

The Angular CLI is a command line interface for building, managing and deploying Angular (version 2+) applications.

The Angular CLI is a command line interface for building, managing and deploying Angular (version 2+) applications. It can be used to generate part of the application, serving in a local server, analysing code quality, etc. It is based on ember-cli project.

Installation

npm install -g @angular/cli

Usage

ng help

Generating and serving an Angular project via a development server

ng new PROJECT-NAME
cd PROJECT-NAME
ng serve

For more information, please visit the following links.

7329 questions
107
votes
6 answers

How Angular builds and runs

Just want to learn how Angular builds and runs behind the scenes? Below is what I understood thus far. Want to know if I missed something. How Angular builds After coding our Angular apps using TypeScript, we use the Angular CLI command to build…
Shaiju T
  • 6,201
  • 20
  • 104
  • 196
106
votes
12 answers

How to speed up the Angular build process

After making some changes in my TypeScript files, each build takes over 20 minutes. I run this command: ng build --output-path=..\..\static\angularjs. If I run it in Microsoft PowerShell, it needs 25 - 30 seconds. This is a lot of…
michael-mammut
  • 2,595
  • 5
  • 28
  • 46
102
votes
6 answers

ng build --prod => Error: Unknown argument: prod

When I try to build my angular project in production environment: ng build --prod --aot the console returns this error: Error: Unknown argument: prod ng serve is working fine and ng build without parameters seems to work too. Why does angular…
Max Himes
  • 1,133
  • 2
  • 3
  • 11
101
votes
5 answers

How to remove package using Angular CLI?

Angular 6 has new CLI command ng add . How can I remove the package using Angular CLI? UPDATE documentation ng add will use your package manager to download new dependencies and invoke an installation script (implemented as a schematic)…
Dmitry Grinko
  • 13,806
  • 14
  • 62
  • 86
100
votes
10 answers

How to upgrade Angular CLI to the latest version

Using ng --version I got: @angular/cli: 1.0.0 which is not the latest release available. Since I have Angular CLI globally installed on my system, in order to upgrade it I tried: npm update angular-cli -g But it does not work, because it stays to…
Francesco Borzi
  • 56,083
  • 47
  • 179
  • 252
94
votes
3 answers

Angular Service Worker - Failed to load resource: the server responded with a status of 504 (Gateway Timeout)

I am using the Angular-CLI 1.6.6 and @angular/service-worker 5.2.5 in our Angular 5.2.5 app. Everything works fine on the local lite-server, as well as on the production server, except for one error message popping in our production environment:…
94
votes
5 answers

What does the angular compiler "compile"?

I was asked that today and was not able to give a proper answer. Typescript transpiles to JS. Then there is tree shaking, "less" (optional) and what else in the process of making a deployment. But nothing like that (afaik) has anything to do with…
codepleb
  • 10,086
  • 14
  • 69
  • 111
93
votes
6 answers

How do I deal with installing peer dependencies in Angular CLI?

I've found myself in an almost endless cycle of errors when trying to update my Angular CLI and NPM. Every time I update, I am met with WARN messages telling me to install peer dependencies (see below), but each time I install a dependency, I am met…
tommy
  • 1,126
  • 1
  • 8
  • 11
90
votes
2 answers

Where does `ng serve` output files to?

ng serve is not building to the path that I have set in my angular-cli.json in apps[0].outDir. ng build works correctly and builds to the path that I have specified.
Daniel Patrick
  • 3,980
  • 6
  • 29
  • 49
89
votes
7 answers

How to Create a specific version of Angular Project using CLI?

My npm version is 5.5.1 and angular cli version is 6.2.1. When I try to create a new project using the command ng new Project_name then it is creating the latest version of Angular (in my case it is creating Angular version ^6.1.0), but I want…
Ravi
  • 1,614
  • 4
  • 14
  • 27
87
votes
4 answers

Angular CLI create .spec files for already existing components

There is an option in .angular-cli.json to disable the automatic creating of *.spec files e.g. for components, see json schema. This is a really nice feature because personally (this is just my opinion) testing the components might not be the thing…
smnbbrv
  • 23,502
  • 9
  • 78
  • 109
87
votes
5 answers

Angular Cli Webpack, How to add or bundle external js files?

I am not sure how to include JS files (vendors) after switching Angular Cli from SystemJs to Webpack. For example Option A I have some js files that were installed via npm. Adding script tags to the head tag like this does not work. Nor does it seem…
khollenbeck
  • 16,028
  • 18
  • 66
  • 101
86
votes
13 answers

How do I support Internet Explorer in an Angular 8 application?

When I generate a project with Angular CLI (8.0.0), I run ng serve, open the application up in Internet Explorer and I am presented with a blank screen. I had a look at the polyfills.ts files and I uncommented the following lines: import…
James Barrett
  • 2,757
  • 4
  • 25
  • 35
85
votes
5 answers

How can I run tests with a headless browser?

Using: ng test Angular CLI runs the tests by default in Chrome, which is great, but what if I need to run them in a console-only environment (headless browser)? Also it would be nice if I can specify if I want browser-less or not each time I run…
Francesco Borzi
  • 56,083
  • 47
  • 179
  • 252
85
votes
14 answers

Angular 9 + CLI (TypeScript) - How to stop generating .spec.ts test files

I know it's kind of a bad practice, but bear with me: I'm using Angular-CLI, particularly ng g to generate all of my classes. However, I'm not interested in any *.spec.ts test files. I know that there are two flags (--inline-template,…
Mohamed Mo Kawsara
  • 4,400
  • 2
  • 27
  • 43