-
Notifications
You must be signed in to change notification settings - Fork 12k
No NgModule metadata found for 'AppModule' (again) #11218
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’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
You wrote in your tsconfig.json
I could be wrong but seems there is no such option here. Anyway your path is incorrect. It should be If you open webpack.config.json you can specify
Also you should inject your scripts in
Another way to solve your issue is use
|
Ah, yes I see -- the angularCompilerOptions are not the same as the AngularCompilerPlugin options, and the mainPath can only be set in the latter not in the former. That does indeed explain it, thank you for the help! Sorry this wasn't a real bug. |
Hmm, I think there's still something going on here that doesn't quite work. The minimal test case I originally came up with did indeed have the problems you pointed out, thank you. We're still having trouble in our real app trying to use AngularCompilerPlugin. It seems related to the fact that it's a hybrid AngularJS and Angular 6 app. Here's another repro, slightly more complicated than the original but incorporating the fixes that you originally pointed out: https://github.com/wiltzius/ng-toolkit/tree/example-breakage-2 I've tried both the Is there some specific way that AngularCompilerPlugin needs to be set up to work with a hybrid AngularJS + Angular app? Thank you again. |
@wiltzius Hey again You should go through the following steps:
with
Don't ask me why is it so :))) Now it's time to get the following error :)
|
Wow! Thank you, once again. That's pretty unexpected haha. I copied that line of code about platformRef bootstrapping directly from the Angular docs: https://angular.io/guide/upgrade-performance#specifying-a-factory-for-the-angular-module So if a specific invocation of platformRef bootstrapping is required by @ngtools/webpack, I wonder if maybe it should be mentioned somewhere in the @ngtools/webpack docs? |
I would like the following code in my main.ts file work with AOT - currently it breaks:
I know I can do replace the main.ts when compiling to cordova, but the above still doesn't work in cordova due to the fact that it is ran inside the |
@HarelM Will this work for you?
|
@alexzuza Thanks for the tip! |
I solve the issue, in the file main.ts, I remove this part .catch(err => console.error(err)); and the final line is just: platformBrowserDynamic().bootstrapModule(AppModule); |
I think that's not great solution for this error...You need to add |
I am facing the same issue and I tried by adding the below line to my tsconfig.app.json file but it didn't work: Can someone please help me with this? |
@alexeagle I think I found the root cause in my case I was having a custom builder and by using it I was getting this error and if I switched to cli one it works totally fine after some debugging if found that compile cli try to read class declaration https://github.com/angular/angular/blob/5332b04f35e60ddb2567b2288efd561e25a2a23b/packages/compiler-cli/src/metadata/collector.ts#L299 I hope it helps someone else short answer make sure typescript version is consistent between your packages and maybe global ng |
if nothing else works try following to create the ngmodule offline
|
Thanks! @alexzuza But why this work in AOT???? |
Might be helpful for someone. Earlier (few months ago) I turned on |
Thanks for reporting this issue. This issue is now obsolete due to changes in the recent releases. Please update to the most recent Angular CLI version. If the problem persists after upgrading, please open a new issue, provide a simple repository reproducing the problem, and describe the difference between the expected and current behavior. |
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 or Feature Request (mark with an
x
)Area
Versions
node v8.11.2
npm version 5.6.0 (tho I use yarn 1.7.0)
MacOS High Sierra
Repro steps
Repro case with instructions here:
https://github.com/wiltzius/ng-toolkit/tree/angular_and_webpack_demystified_step3
The log given by the failure
app.js:861 Uncaught Error: No NgModule metadata found for 'class{}'.
at e.resolve (app.js:861)
at e.getNgModuleMetadata (app.js:839)
at e._loadModules (app.js:1065)
at e._compileModuleAndComponents (app.js:1065)
at e.compileModuleAsync (app.js:1065)
at e.compileModuleAsync (app.js:1365)
at e.bootstrapModule (app.js:220)
at Module. (app.js:1373)
at n (app.js:1)
at app.js:1
Desired functionality
The @ngtools/webpack plugin doesn't produce any runtime errors?
Mention any other details that might be useful
This is roughly the same issue that's described in issue #8798 however that issue has a lot of different complaints in it and has been closed, so I thought it would be cleaner as a new one.
The text was updated successfully, but these errors were encountered: