ERROR in No NgModule metadata found for '{Module Name}'












0














I am using the following Version of CLI:



ngular CLI: 6.2.7
Node: 10.6.0
OS: darwin x64
Angular: 6.1.10
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

Package Version
-----------------------------------------------------------
@angular-devkit/architect 0.8.7
@angular-devkit/build-angular 0.8.7
@angular-devkit/build-optimizer 0.8.7
@angular-devkit/build-webpack 0.8.7
@angular-devkit/core 0.8.7
@angular-devkit/schematics 0.8.7
@angular/cli 6.2.7
@ngtools/webpack 6.2.7
@schematics/angular 0.8.7
@schematics/update 0.8.7
rxjs 6.2.2
typescript 2.9.2
webpack 4.16.4


I created a child ng Module with name char-routing.module.ts and when i tried to crate class its throwing error When i run the ng serve it Throw following Error:



ERROR in No NgModule metadata found for 'CharRoutingModule'.


I am using lazyloading of NgModule loadChildren: './add-character/add-character.component#CharRoutingModule'
I am adding my source of my two file. I am not able to replicate the issue why this happen, I am new in angular so, I don't have much more idea about it.
Code of char-routing.module.ts



import { NgModule } from '@angular/core';
import { AddCharacterComponent } from './add-character.component';
import { RouterModule } from '@angular/router';

@NgModule({
imports: [RouterModule.forChild([
{path: '', component: AddCharacterComponent}
])],
declarations: [AddCharacterComponent]
})
export class CharRoutingModule {

}


Code of add-character.component.ts



import { StarWarService } from './../star-war.service';
import { Component, OnInit } from '@angular/core';

@Component({
selector: 'app-add-character',
templateUrl: './add-character.component.html',
styleUrls: ['./add-character.component.css']
})
export class AddCharacterComponent implements OnInit {
ablavelSide: {display: string, value: string} = [
{display: 'None', value: ''},
{display: 'Light', value: 'light'},
{display: 'Dark', value: 'dark'}
];
swService: StarWarService;
constructor(serive: StarWarService) {
this.swService = serive;
}

ngOnInit() {
}

onSubmit (form) {
console.log(form);
if (form.invalid) {
return;
}
this.swService.addCharracter(form.value.name, form.value.side);
form.reset();
}
}


This is the code which i am using. Please help me.










share|improve this question
























  • Please add the code for your CharRoutingModule and add-character.component.ts file as well.
    – SiddAjmera
    Nov 10 at 17:17












  • I just added the files source code.
    – Rajeev
    Nov 10 at 17:35
















0














I am using the following Version of CLI:



ngular CLI: 6.2.7
Node: 10.6.0
OS: darwin x64
Angular: 6.1.10
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

Package Version
-----------------------------------------------------------
@angular-devkit/architect 0.8.7
@angular-devkit/build-angular 0.8.7
@angular-devkit/build-optimizer 0.8.7
@angular-devkit/build-webpack 0.8.7
@angular-devkit/core 0.8.7
@angular-devkit/schematics 0.8.7
@angular/cli 6.2.7
@ngtools/webpack 6.2.7
@schematics/angular 0.8.7
@schematics/update 0.8.7
rxjs 6.2.2
typescript 2.9.2
webpack 4.16.4


I created a child ng Module with name char-routing.module.ts and when i tried to crate class its throwing error When i run the ng serve it Throw following Error:



ERROR in No NgModule metadata found for 'CharRoutingModule'.


I am using lazyloading of NgModule loadChildren: './add-character/add-character.component#CharRoutingModule'
I am adding my source of my two file. I am not able to replicate the issue why this happen, I am new in angular so, I don't have much more idea about it.
Code of char-routing.module.ts



import { NgModule } from '@angular/core';
import { AddCharacterComponent } from './add-character.component';
import { RouterModule } from '@angular/router';

@NgModule({
imports: [RouterModule.forChild([
{path: '', component: AddCharacterComponent}
])],
declarations: [AddCharacterComponent]
})
export class CharRoutingModule {

}


Code of add-character.component.ts



import { StarWarService } from './../star-war.service';
import { Component, OnInit } from '@angular/core';

@Component({
selector: 'app-add-character',
templateUrl: './add-character.component.html',
styleUrls: ['./add-character.component.css']
})
export class AddCharacterComponent implements OnInit {
ablavelSide: {display: string, value: string} = [
{display: 'None', value: ''},
{display: 'Light', value: 'light'},
{display: 'Dark', value: 'dark'}
];
swService: StarWarService;
constructor(serive: StarWarService) {
this.swService = serive;
}

ngOnInit() {
}

onSubmit (form) {
console.log(form);
if (form.invalid) {
return;
}
this.swService.addCharracter(form.value.name, form.value.side);
form.reset();
}
}


This is the code which i am using. Please help me.










share|improve this question
























  • Please add the code for your CharRoutingModule and add-character.component.ts file as well.
    – SiddAjmera
    Nov 10 at 17:17












  • I just added the files source code.
    – Rajeev
    Nov 10 at 17:35














0












0








0







I am using the following Version of CLI:



ngular CLI: 6.2.7
Node: 10.6.0
OS: darwin x64
Angular: 6.1.10
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

Package Version
-----------------------------------------------------------
@angular-devkit/architect 0.8.7
@angular-devkit/build-angular 0.8.7
@angular-devkit/build-optimizer 0.8.7
@angular-devkit/build-webpack 0.8.7
@angular-devkit/core 0.8.7
@angular-devkit/schematics 0.8.7
@angular/cli 6.2.7
@ngtools/webpack 6.2.7
@schematics/angular 0.8.7
@schematics/update 0.8.7
rxjs 6.2.2
typescript 2.9.2
webpack 4.16.4


I created a child ng Module with name char-routing.module.ts and when i tried to crate class its throwing error When i run the ng serve it Throw following Error:



ERROR in No NgModule metadata found for 'CharRoutingModule'.


I am using lazyloading of NgModule loadChildren: './add-character/add-character.component#CharRoutingModule'
I am adding my source of my two file. I am not able to replicate the issue why this happen, I am new in angular so, I don't have much more idea about it.
Code of char-routing.module.ts



import { NgModule } from '@angular/core';
import { AddCharacterComponent } from './add-character.component';
import { RouterModule } from '@angular/router';

@NgModule({
imports: [RouterModule.forChild([
{path: '', component: AddCharacterComponent}
])],
declarations: [AddCharacterComponent]
})
export class CharRoutingModule {

}


Code of add-character.component.ts



import { StarWarService } from './../star-war.service';
import { Component, OnInit } from '@angular/core';

@Component({
selector: 'app-add-character',
templateUrl: './add-character.component.html',
styleUrls: ['./add-character.component.css']
})
export class AddCharacterComponent implements OnInit {
ablavelSide: {display: string, value: string} = [
{display: 'None', value: ''},
{display: 'Light', value: 'light'},
{display: 'Dark', value: 'dark'}
];
swService: StarWarService;
constructor(serive: StarWarService) {
this.swService = serive;
}

ngOnInit() {
}

onSubmit (form) {
console.log(form);
if (form.invalid) {
return;
}
this.swService.addCharracter(form.value.name, form.value.side);
form.reset();
}
}


This is the code which i am using. Please help me.










share|improve this question















I am using the following Version of CLI:



ngular CLI: 6.2.7
Node: 10.6.0
OS: darwin x64
Angular: 6.1.10
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

Package Version
-----------------------------------------------------------
@angular-devkit/architect 0.8.7
@angular-devkit/build-angular 0.8.7
@angular-devkit/build-optimizer 0.8.7
@angular-devkit/build-webpack 0.8.7
@angular-devkit/core 0.8.7
@angular-devkit/schematics 0.8.7
@angular/cli 6.2.7
@ngtools/webpack 6.2.7
@schematics/angular 0.8.7
@schematics/update 0.8.7
rxjs 6.2.2
typescript 2.9.2
webpack 4.16.4


I created a child ng Module with name char-routing.module.ts and when i tried to crate class its throwing error When i run the ng serve it Throw following Error:



ERROR in No NgModule metadata found for 'CharRoutingModule'.


I am using lazyloading of NgModule loadChildren: './add-character/add-character.component#CharRoutingModule'
I am adding my source of my two file. I am not able to replicate the issue why this happen, I am new in angular so, I don't have much more idea about it.
Code of char-routing.module.ts



import { NgModule } from '@angular/core';
import { AddCharacterComponent } from './add-character.component';
import { RouterModule } from '@angular/router';

@NgModule({
imports: [RouterModule.forChild([
{path: '', component: AddCharacterComponent}
])],
declarations: [AddCharacterComponent]
})
export class CharRoutingModule {

}


Code of add-character.component.ts



import { StarWarService } from './../star-war.service';
import { Component, OnInit } from '@angular/core';

@Component({
selector: 'app-add-character',
templateUrl: './add-character.component.html',
styleUrls: ['./add-character.component.css']
})
export class AddCharacterComponent implements OnInit {
ablavelSide: {display: string, value: string} = [
{display: 'None', value: ''},
{display: 'Light', value: 'light'},
{display: 'Dark', value: 'dark'}
];
swService: StarWarService;
constructor(serive: StarWarService) {
this.swService = serive;
}

ngOnInit() {
}

onSubmit (form) {
console.log(form);
if (form.invalid) {
return;
}
this.swService.addCharracter(form.value.name, form.value.side);
form.reset();
}
}


This is the code which i am using. Please help me.







angular webpack






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 10 at 17:34

























asked Nov 10 at 17:15









Rajeev

664




664












  • Please add the code for your CharRoutingModule and add-character.component.ts file as well.
    – SiddAjmera
    Nov 10 at 17:17












  • I just added the files source code.
    – Rajeev
    Nov 10 at 17:35


















  • Please add the code for your CharRoutingModule and add-character.component.ts file as well.
    – SiddAjmera
    Nov 10 at 17:17












  • I just added the files source code.
    – Rajeev
    Nov 10 at 17:35
















Please add the code for your CharRoutingModule and add-character.component.ts file as well.
– SiddAjmera
Nov 10 at 17:17






Please add the code for your CharRoutingModule and add-character.component.ts file as well.
– SiddAjmera
Nov 10 at 17:17














I just added the files source code.
– Rajeev
Nov 10 at 17:35




I just added the files source code.
– Rajeev
Nov 10 at 17:35












1 Answer
1






active

oldest

votes


















1














You're supplying the wrong path to your CharRoutingModule file.



loadChildren: './add-character/add-character.component#CharRoutingModule'


should have been



loadChildren: './add-character/char-routing.module#CharRoutingModule'


Ideally though, there should be a CharModule that should be referenced in the loadChildren and then a CharRoutingModule that would contain the route config for CharModule






share|improve this answer





















  • Thanks @SiddAjmera it's working fine for me.
    – Rajeev
    Nov 10 at 17:46











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53241446%2ferror-in-no-ngmodule-metadata-found-for-module-name%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














You're supplying the wrong path to your CharRoutingModule file.



loadChildren: './add-character/add-character.component#CharRoutingModule'


should have been



loadChildren: './add-character/char-routing.module#CharRoutingModule'


Ideally though, there should be a CharModule that should be referenced in the loadChildren and then a CharRoutingModule that would contain the route config for CharModule






share|improve this answer





















  • Thanks @SiddAjmera it's working fine for me.
    – Rajeev
    Nov 10 at 17:46
















1














You're supplying the wrong path to your CharRoutingModule file.



loadChildren: './add-character/add-character.component#CharRoutingModule'


should have been



loadChildren: './add-character/char-routing.module#CharRoutingModule'


Ideally though, there should be a CharModule that should be referenced in the loadChildren and then a CharRoutingModule that would contain the route config for CharModule






share|improve this answer





















  • Thanks @SiddAjmera it's working fine for me.
    – Rajeev
    Nov 10 at 17:46














1












1








1






You're supplying the wrong path to your CharRoutingModule file.



loadChildren: './add-character/add-character.component#CharRoutingModule'


should have been



loadChildren: './add-character/char-routing.module#CharRoutingModule'


Ideally though, there should be a CharModule that should be referenced in the loadChildren and then a CharRoutingModule that would contain the route config for CharModule






share|improve this answer












You're supplying the wrong path to your CharRoutingModule file.



loadChildren: './add-character/add-character.component#CharRoutingModule'


should have been



loadChildren: './add-character/char-routing.module#CharRoutingModule'


Ideally though, there should be a CharModule that should be referenced in the loadChildren and then a CharRoutingModule that would contain the route config for CharModule







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 10 at 17:38









SiddAjmera

12.3k21137




12.3k21137












  • Thanks @SiddAjmera it's working fine for me.
    – Rajeev
    Nov 10 at 17:46


















  • Thanks @SiddAjmera it's working fine for me.
    – Rajeev
    Nov 10 at 17:46
















Thanks @SiddAjmera it's working fine for me.
– Rajeev
Nov 10 at 17:46




Thanks @SiddAjmera it's working fine for me.
– Rajeev
Nov 10 at 17:46


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53241446%2ferror-in-no-ngmodule-metadata-found-for-module-name%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







這個網誌中的熱門文章

Academy of Television Arts & Sciences

L'Équipe

1995 France bombings