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
251
votes
16 answers

How to execute only one test spec with angular-cli

I have Angular2 project build with Angular-CLI (beta 20). Is there a way to run tests against only one selected spec file? I used to have a project based on Angular2 quick start, and I could manually add specs to jasmine file. But I don't know how…
Zielu
  • 8,312
  • 4
  • 28
  • 41
246
votes
8 answers

How to set environment via `ng serve` in Angular 6

I am trying to update my Angular 5.2 app to Angular 6. I successfully followed instructions in the Angular update guide (including the update of angular-cli to v6), and now I am trying to serve the app via ng serve --env=local But this gives me…
Martin Adámek
  • 16,771
  • 5
  • 45
  • 64
244
votes
15 answers

Running a single test file

Is there a way to run ng test for a single file instead of for the entire test suite? Ideally, I'd like to get the quickest possible feedback loop when I'm editing a file, but karma executes the whole suite on each save, which is a bit slow when…
Elliot Larson
  • 10,669
  • 5
  • 38
  • 57
231
votes
17 answers

Checking version of angular-cli that's installed?

Is there a way to check the specific version of angular-cli that's installed globally on my machine? I'm in a Windows environment. *npm -v* and *node -v* only gives me the version of npm and node respectively, and I can't seem to find any commands…
bunndan
  • 2,717
  • 3
  • 18
  • 20
217
votes
6 answers

When to use 'npm start' and when to use 'ng serve'?

ng serve serves an Angular project via a development server   npm start runs an arbitrary command specified in the package's "start" property of its "scripts" object. If no "start" property is specified on the "scripts" object, it will run…
ishandutta2007
  • 16,676
  • 16
  • 93
  • 129
206
votes
45 answers

Angular CLI Error: The serve command requires to be run in an Angular project, but a project definition could not be found

When running the terminal commands ng server or ng serve --live-reload=true, I'm getting this issue: The serve command requires to be run in an Angular project, but a project definition could not be found.
Gurpreet Singh
  • 3,061
  • 5
  • 19
  • 36
206
votes
11 answers

How to load image (and other assets) in Angular an project?

I'm pretty new to Angular so I'm not sure the best practice to do this. I used angular-cli and ng new some-project to generate a new app. In it created an "images" folder in the "assets" folder, so now my images folder is src/assets/images In…
user3183717
  • 4,427
  • 6
  • 20
  • 42
205
votes
17 answers

Angular-cli from css to scss

I've read the documentation, which says that if I want to use scss I have to run the following command: ng set defaults.styleExt scss But when I do that and make that file, I still receive this error in my console: styles.bundle.js:33Uncaught…
Jamie
  • 10,302
  • 32
  • 103
  • 186
201
votes
21 answers

How to get the Angular version?

I installed the @angular/cli package via npm using: npm install -g @angular/cli The version 1.4.2 of @angular/cli has been successfully installed. That is not the Angular version, but the CLI version. After running ng new myapp how can I check…
vinibrsl
  • 6,563
  • 4
  • 31
  • 44
198
votes
23 answers

Error: Local workspace file ('angular.json') could not be found

I have travis-ci integrated with my GitHub account (https://github.com/pradeep0601/Angular5-Router-App). When I updated @angular/cli version from 1.7.4 to 6.0.0-rc.3, the build started failing with an error: Local workspace file ('angular.json')…
Pradeep
  • 12,309
  • 3
  • 20
  • 25
198
votes
42 answers

ng: command not found while creating new project using angular-cli

Installed angular-cli globally using (npm install -g angular-cli) but when I'm trying to create project using ng new my-project it is throwing error: ng: command not found
lego
  • 2,081
  • 2
  • 10
  • 4
197
votes
13 answers

Set default host and port for ng serve in config file

I want to know if i can set a host and a port in a config file so I don't have to type ng serve --host foo.bar --port 80 instead of just ng serve
cre8
  • 13,012
  • 8
  • 37
  • 61
196
votes
43 answers

Message "the term 'ng' is not recognized as the name of a cmdlet"

Today, while working through some basic AngularJS introduction, I ran into a problem. I opened PowerShell to get going on the project. NPM worked. I was able to install Angular using: npm install -g @angular/cli Anytime I tried to run ng, I would…
Wauna
  • 2,226
  • 2
  • 10
  • 11
192
votes
33 answers

How to change Angular CLI favicon

How can I change the default favicon that is set by the Angular CLI? I have tried many things, but it always shows the Angular logo as the favicon, even though I have deleted that icon (favicon.ico in src folder). It still shows, and I don't know…
user4914839
182
votes
16 answers

How to decrease prod bundle size?

I have a simple app, initialized by angular-cli. It display some pages relative to 3 routes. I have 3 components. On one of this page I use lodash and Angular 2 HTTP modules to get some data (using RxJS Observables, map and subscribe). I display…
BlackHoleGalaxy
  • 9,160
  • 17
  • 59
  • 103