Questions tagged [angular-cli]
The Angular CLI is a command line interface for building, managing and deploying Angular (version 2+) applications.
7,051
questions
821
votes
45
answers
1.4m
views
Could not find module "@angular-devkit/build-angular"
After updating to Angular 6.0.1, I get the following error on ng serve:
Could not find module "@angular-devkit/build-angular" from "/home/Projects/myProjectName".
Error: Could not find module "@...
466
votes
22
answers
557k
views
Global Angular CLI version greater than local version
When running ng serve I get this warning about my global CLI version being greater than my local version. I don't notice any issues from this warning, but I was wondering if the two versions should be ...
438
votes
22
answers
589k
views
How to change angular port from 4200 to any other
I want to use 5000 instead of 4200.
I have tried to create a file on root name ember-cli and put JSON according to the code below:
{
"port": 5000
}
But my app still runs on 4200 instead ...
386
votes
12
answers
260k
views
How to bundle an Angular app for production
What is the best method to bundle Angular (version 2, 4, 6, ...) for production on a live web server.
Please include the Angular version within answers so we can track better when it moves to later ...
351
votes
18
answers
215k
views
Angular CLI SASS options
I'm new to Angular and I'm coming from the Ember community. Trying to use the new Angular-CLI based off of Ember-CLI.
I need to know the best way to handle SASS in a new Angular project. I tried ...
330
votes
21
answers
433k
views
How to generate components in a specific folder with Angular CLI?
I am using Angular 4 with Angular CLI and I am able to create a new component with the following command.
E:\HiddenWords>ng generate component plainsight
But I need to generate a child component ...
324
votes
51
answers
879k
views
ng is not recognized as an internal or external command
Running windows 7 Professional 32bit.
I tried running npm install -g angular-cli both under normal or admin.
I also tried adding it to the Enviorment Variables under PATH: (C:\Users\Administrator\...
303
votes
29
answers
276k
views
How to add font-awesome to Angular 2 + CLI project
I'm using Angular 2+ and Angular CLI.
How do I add font-awesome to my project?
294
votes
40
answers
588k
views
How to add bootstrap to an angular-cli project
We want to use bootstrap 4 (4.0.0-alpha.2) in our app generated with angular-cli 1.0.0-beta.5 (w/ node v6.1.0).
After getting bootstrap and its dependencies with npm, our first approach consisted in ...
283
votes
6
answers
149k
views
tslint / codelyzer / ng lint error: "for (... in ...) statements must be filtered with an if statement"
Lint error message:
src/app/detail/edit/edit.component.ts[111, 5]: for (... in ...)
statements must be filtered with an if statement
Code snippet (It is a working code. It is also available at ...
282
votes
14
answers
472k
views
What is the best way to delete a component with CLI
I tried using "ng destroy component foo" and it tells me "The destroy command is not supported by Angular-CLI"
How do we properly delete components with Angular CLI?
269
votes
4
answers
289k
views
Why powershell does not run Angular commands?
I have started to learn Angular but I note that powershell in Windows gives me an error whenever I make an angular command like:
ng new new-app
or
ng serve
this is the error what I got:
ng : File ...
255
votes
11
answers
173k
views
How to rename a component in Angular CLI?
Is there any shortcut to rename a component with the Angular CLI other than manually editing all the component files such as folder name, .css, .ts, spec.ts and app.module.ts?
232
votes
8
answers
163k
views
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 ...
223
votes
32
answers
295k
views
Create component & add it to a specific module with Angular-CLI
I'm starting to use angular-cli and I've already read a lot to find an answer about what I want to do...no success, so I came here.
Is there a way to create a component to a new module?
e.g.: ng g ...
223
votes
14
answers
512k
views
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 ...
219
votes
14
answers
200k
views
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 ...
217
votes
12
answers
137k
views
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 ...
198
votes
43
answers
637k
views
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 ...
197
votes
6
answers
217k
views
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 ...
196
votes
23
answers
277k
views
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 ...
189
votes
13
answers
276k
views
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
177
votes
17
answers
167k
views
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 ...
174
votes
9
answers
158k
views
ERROR in The Angular Compiler requires TypeScript >=3.1.1 and <3.2.0 but 3.2.1 was found instead
I am getting this error
ERROR in The Angular Compiler requires TypeScript >=3.1.1 and <3.2.0 but 3.2.1 was found instead.
Seems like Typescript updated but the Angular Compiler doesn't like ...
174
votes
19
answers
464k
views
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....
172
votes
2
answers
151k
views
Is there a compatibility list for Angular / Angular-CLI and Node.js?
I periodically run into the problem, having to spin up old Angular projects with deprecated dependencies of Angular.
Because I unsually run the latest Node.js version (at least lates LTS version) I ...
169
votes
15
answers
154k
views
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 ...
167
votes
38
answers
303k
views
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
166
votes
33
answers
223k
views
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 ...
165
votes
10
answers
432k
views
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, ...
153
votes
3
answers
114k
views
"Error: No provider for router" while writing Karma-Jasmine unit test cases
We have done one angular2 project set up and inside that created one module (my-module) and inside that module created one component (my-new-component) using following cmd commands:
ng new ...
152
votes
11
answers
58k
views
Angular tests failing with Failed to execute 'send' on 'XMLHttpRequest'
I am trying to test my angular 4.1.0 component -
export class CellComponent implements OnInit {
lines: Observable<Array<ILine>>;
@Input() dep: string;
@Input() embedded: boolean;
@...
150
votes
7
answers
158k
views
How to iterate using ngFor loop Map containing key as string and values as map iteration
I am new to angular 5 and trying to iterate the map containing another map in typescript.
How to iterate below this kind of map in angular
below is code for component:
import { Component, OnInit} ...
150
votes
9
answers
140k
views
angular-cli server - how to specify default port
Using angular-cli with the ng serve command, how can I specify a default port so I do not need to manually pass the --port flag every time?
I'd like to change from the default port 4200.
147
votes
37
answers
395k
views
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 @...
146
votes
14
answers
254k
views
how to end ng serve or firebase serve
I've been doing web development with Angular2 and have been using both Angular2 and Firebase to run local servers. I haven't been able to find a command similar to typing quit when using Ionic to ...
145
votes
27
answers
181k
views
You seem to not be depending on "@angular/core". This is an error
I want to create an angular 2 App with angular cli
I have written in the cmd:
npm install angular-cli -g
then:
ng firstngapp
but it show me an error when I write npm start !
I don't ...
145
votes
12
answers
33k
views
Implementing a plugin architecture / plugin system / pluggable framework in Angular 2, 4, 5, 6
Update 5/24/2018: We are now +3 versions of Angular from my original post and still don't have a final workable solution. Lars Meijdam (@LarsMeijdam) has come up with an interesting approach which is ...
142
votes
5
answers
112k
views
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 ...
140
votes
20
answers
631k
views
How to uninstall/upgrade Angular CLI?
When I try to create a new project with Angular CLI, with:
ng n app
I get this error:
fs.js:640 return binding.open(pathModule._makeLong(path),
stringToFlags(flags), mode);
...
135
votes
10
answers
177k
views
how to change the dist-folder path in angular-cli after 'ng build'
I would like to use angular-cli with asp.net core and I need to know how I can change the path of the dist folder
134
votes
8
answers
128k
views
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');
...
130
votes
7
answers
91k
views
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 ...
130
votes
4
answers
116k
views
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 ...
129
votes
20
answers
104k
views
How to get rid of the warning .ts file is part of the TypeScript compilation but it's unused
I Just updated angular to latest 9.0.0-next.4. I am not using routing but suddenly after updating I keep seeing this warning. How Do I remove this warning
WARNING in src/war/angular/src/app/app-...
127
votes
20
answers
163k
views
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 ...
126
votes
2
answers
59k
views
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
<input id="name&...
125
votes
9
answers
76k
views
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,...
124
votes
17
answers
347k
views
How to install a specific version of Angular with Angular CLI?
I searched through google and angular cli doc but couldn't find any way to install a specific version of Angular using Angular CLI. is it even possible?
123
votes
25
answers
131k
views
"Invalid Host header" when running Angular/cli development server c9.io
Current command: ng serve --host --public $IP:$PORT
Results on my website:
Invalid Host header