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
148
votes
4 answers

angular-cli where is webpack.config.js file - new angular6 does not support ng eject

UPDATE: December 2018 (see 'Aniket' answer) With Angular CLI 6 you need to use builders as ng eject is deprecated and will soon be removed in 8.0 UPDATE: June 2018: Angular 6 does not support ng eject** UPDATE: February 2017: use ng eject UPDATE:…
stackdave
  • 6,655
  • 9
  • 37
  • 56
145
votes
5 answers

What's the difference between --base-href and --deploy-url parameters of angular-cli tool

The documentation of Angular informs one should use --base-href parameter in the Angular application build for production when it's going to be deployed in a subfolder: If you copy the files into a server sub-folder, append the build…
Rodrigo
  • 2,313
  • 2
  • 15
  • 23
140
votes
7 answers

Package '@angular/cli' is not a dependency

I am getting the following error when I try to run the command ng update @angular/cli @angular/core --allow-dirty Repository is not clean. Update changes will be mixed with pre-existing changes. Using package manager: 'npm' Collecting installed…
shayanmalinda
  • 1,925
  • 3
  • 12
  • 23
140
votes
8 answers

Cannot find name 'require' after upgrading to Angular4

I want to use Chart.js within my Angular project. In previous Angular2 versions, I have been doing this well by using a 'chart.loader.ts' which has: export const { Chart } = require('chart.js'); Then in the component code I just import { Chart }…
Thomas Wang
  • 2,031
  • 3
  • 17
  • 28
140
votes
7 answers

How to include custom files with angular-cli build?

RE: Angular2 2.0.0, angular-cli v1.0.0-beta.11-webpack.8 How do I tell angular-cli to include a file from "src/assets" in the root of "dist" when it builds? We deploy to a Windows host and need to include a "web.config" file to tell IIS to route…
Kizmar
  • 2,465
  • 3
  • 20
  • 27
137
votes
13 answers

angular-cli server - how to proxy API requests to another server?

With the angular-cli ng serve local dev server, it's serving all the static files from my project directory. How can I proxy my AJAX calls to a different server?
elwyn
  • 10,360
  • 11
  • 42
  • 52
132
votes
26 answers

How to create a new component in Angular 4 using CLI

In angular 2 I use ng g c componentname But It is not supported in Angular 4, so I created it manually, but it shows error that it is not a module.
surbhiGoel
  • 1,436
  • 2
  • 8
  • 12
131
votes
2 answers

angular2 testing: Can't bind to 'ngModel' since it isn't a known property of 'input'

I am trying to test angular2 two-way binding for control input. Here is the error: Can't bind to 'ngModel' since it isn't a known property of 'input'. The app.component.html
beewest
  • 4,486
  • 7
  • 36
  • 63
129
votes
20 answers

You have to be inside an angular-cli project in order to use the build command after reinstall of angular-cli

I had the latest angular-cli installed globally and my project was building successfully. While reading a suggested solution for another issue, (https://github.com/angular/angular-cli/issues/917) I uninstalled the global angular-cli and installed…
grim_i_am
  • 3,664
  • 5
  • 19
  • 19
127
votes
9 answers

Angular Karma Jasmine Error: Illegal state: Could not load the summary for directive

I'm developing a github repository (with angular 7 and angular-cli), and I have some tests with Karma and Jasmine working in the master branch. Now I'm trying to add lazy loading feature, the thing is, that the tests that before passed, now they do…
ismaestro
  • 7,561
  • 8
  • 37
  • 50
123
votes
33 answers

Generating Component without spec.ts file in Angular 2+

Is there a way to get rid of the spec.ts file in Angular 2+, whenever I create a new component. I know this is for testing purpose but what if I don't need it. May be there is some setting to disable this specific testing file.
saadeez
  • 1,588
  • 3
  • 11
  • 17
119
votes
12 answers

Generate a routing module while creating a module in angular-cli

I recently started implementing lazy loading in my application. I was wondering whether there is any way to create a routing.module.ts while generating a new module in angular-cli application other than creating it manually?
Saiyaff Farouk
  • 5,103
  • 4
  • 24
  • 38
117
votes
17 answers

How do I debug a "[object ErrorEvent] thrown" error in my Karma/Jasmine tests?

I have several failing tests that only output [object ErrorEvent] thrown. I don't see anything in the console that helps me pinpoint the offending code. Is there something I need to do to track these down? [EDIT]: I'm running Karma v1.70, Jasmine…
Darrell Brogdon
  • 6,843
  • 9
  • 47
  • 62
111
votes
4 answers

Angular cli - how to disable auto reload when ng serve

When serving my app with the Angular cli, how do I disable auto-reload? ng --help mentions the --live-reload option, but I can't make it work. ng serve --live-reload=false or ng serve --live-reload false do not work EDIT : it seems to be a bug…
maxbellec
  • 16,093
  • 10
  • 36
  • 43
109
votes
9 answers

Missing write access in mac to /usr/local/lib/node_modules

I am trying to install angular cli but it's show me Missing write access to /usr/local/lib/node_modules so, how can I fix it in my mac i try it may time but, not getting exact answer npm WARN checkPermissions Missing write access to…
Kundan Kumar Mourya
  • 1,191
  • 2
  • 8
  • 11