-
Notifications
You must be signed in to change notification settings - Fork 24.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
ERROR in No NgModule metadata found for 'AppModule' #35143
Comments
Hi, can you try to update |
Thanks @alan-agius4 I will surely do that in a few hours and let you all know the outcome. |
No @alan-agius4 same issue. |
everything is up to date I have the same problem. main.ts import { enableProdMode } from '@angular/core';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { AppModule } from './app/app.module';
import { environment } from './environments/environment';
import 'hammerjs';
if (environment.production) {
enableProdMode();
}
document.addEventListener('DOMContentLoaded', () => {
platformBrowserDynamic().bootstrapModule(AppModule)
.catch(err => console.error(err));
}); package.json "devDependencies": {
"@angular-devkit/build-angular": "0.803.23",
"@angular/cli": "8.3.23",
"@angular/compiler-cli": "8.2.14",
"@angular/language-service": "8.2.14",
"@types/jasmine": "3.5.0",
"@types/jasminewd2": "2.0.8",
"@types/moment": "2.13.0",
"@types/node": "12.12.24",
"codelyzer": "5.2.1",
"concurrently": "5.0.2",
"jasmine-core": "3.5.0",
"jasmine-spec-reporter": "4.2.1",
"karma": "4.4.1",
"karma-chrome-launcher": "3.1.0",
"karma-coverage-istanbul-reporter": "2.1.1",
"karma-jasmine": "3.1.0",
"karma-jasmine-html-reporter": "1.5.1",
"protractor": "5.4.2",
"ts-loader": "6.2.1",
"ts-node": "8.6.2",
"tslint": "5.20.1",
"typescript": "3.5.3",
"webpack-cli": "3.3.10"
} |
it's my mistakes. work for me sorry. |
Closed as it seem the user solved the issue. |
@alan-agius4 I haven't solved the issue and need you guys input. I don't know why you closed the issue assuming something I never posted. Please reopen the issue. |
@TriumphTruth sorry got confused by the other comment. |
Heya, regarding the weird behaviour during The error during I don't think we can help much with the details in your original issue since that's not code we can copy over to reproduce the error. My suggestion would be start removing parts of your code and take it down to the minimal example that still shows the error, then putting that on a github repository and sharing it here. I know this sounds like a lot of work but it's still the best way of getting some help in open source. If you provide a reproduction anyone can look at it and try to fix the actual problem. But without a reproduction everyone is just guessing and suggesting random things that might or might not have anything to do it with and it's just a waste of time for everyone involved. |
@filipesilva I will try to do this tonight and get back to the community. Thanks for the guidance. Actually I have got to a point where I am worried about removal.... resulting in further deterioration of the project....... Nevermind, I think there is nothing else left to loose. So lets see. Will update here what happens. |
UpdateI have been able to isolate the ng serve issue. But don't quite understand why that is the case. If app.module.ts contains the reference of my TypesUtilsService, I get the Error in No NgModule metadata found for 'App Module' TypesUtilsService class:
It is basically just a helper function class. Can anybody make any sense of this? Build issue is still there. And removal of the reference from App.Module.TS does not cause build to succeed. |
UpdateI was able to solve the build issue as well. But haven't been able to quite understand the what is causing the issue. After having been able to single out the problematic service; the TypesUtilsService. I removed most of the functions I had in this file, and for now kept the bare minimum which I am using and is also not interfering in the application build. Now the file looks like this:
I am clueless about why it was causing an issue before. I am in the middle of some tight deadlines, if someone can research it out it will be better. Else I will update later on if I am able to pin point the function or property causing that irregular errors. Hope this helps. |
Heya @TriumphTruth, thanks for the repro! I tried using the full service (the one in https://github.com/angular/angular-cli/issues/16706#issuecomment-578398531) in a new project with the latest 9.0.0 RC, and saw this error:
I replaced it with Then I also disabled the Ivy compiler (new apps have it enabled by default) and I saw this compilation error:
Also odd that I only saw this error when adding the file on a rebuild, I couldn't get the full stack trace on initial build. I don't know what this error means, but it goes away when I use your reduced version of the file in https://github.com/angular/angular-cli/issues/16706#issuecomment-578406419. This might be the cause of the problem you are seeing. But from the logs this looks like a compiler error. Will transfer it over to the main repository for investigation. |
The issue is that your class defines a The
with one metadata entry for each member of the class. Because this object has a The workaround is to not declare a member with the name |
Thank you for investigating this @filipesilva . It makes total sense of the error you mentioned. The problem I had was there was no mention of any error during the compilation. Feels good that version 9.0.0 is accounting and reporting the error correctly. |
@alxhub makes sense, I will make this change and work through my project.... But should there not be a reasonable stacktrace at least? |
This isn't an "error" - you're allowed to have a member function named |
Sounds reasonable. 馃憤 |
Another observation is that in my previous project, I had been using the same methods as the following: library.ts
I never faced this issue in it. That project has the following configuration: package.json
I think it is because function itself is not a class and hence it proceeded with no errors? It never collected any metadata of itself except the arguments, I assume. |
The Ivy compiler no longer has a metadata collector that was prone to unsupported syntax issues, so closing as resolved. |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
馃悶 Bug report
Command
Is this a regression?
It started happening in the same version without any version upgrade of any sort.
Description
There are 2 parts of the BUG. 1 during serve and 1 during build creation.
Description During Serve
If I need to tell this clearly, it can only be said that this bug occurred while doing development, And no changes to AppModule was made during that time. You hit npm start and you get the following error:
ERROR in No NgModule metadata found for 'AppModule'.
You save any file again and it will start compiling again and compile successfully.
Description during build
It runs the build and fails with the following error:
ERROR in members.hasOwnProperty is not a function
馃敩 Minimal Reproduction
I don't know how to reproduce it. It has occurred during development and without any upgrade to any packages.
馃敟 Exception or Error
Exception on SERVE:
No exception can be found except for the above error as told in the description.
Exception on BUILD:
No exception could be found except for the above error. But I will still put some details here:
馃實 Your Environment
Anything else relevant?
I have performed almost all the work arounds I found in the issues earlier reported but none of them worked. Like, adding the AppModule to
tsconfig.app.json
. Making sureconst bootstrap = () => platformBrowserDynamic().bootstrapModule(AppModule);
is in the one line inmain.ts
. and host of other steps. But none of them works. Please help.My main.ts
My App.module.ts
My app-routing.module.ts
The text was updated successfully, but these errors were encountered: