angular-cli: "ERROR in Error: No NgModule metadata found for 'AppModule'." After Angular 5.2.1 and CLI 1.6.5 update
Versions
Angular CLI: 1.6.5
Node: 9.4.0
OS: darwin x64
Angular: 5.2.1
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router
@angular/cdk: 5.1.0
@angular/cli: 1.6.5
@angular/material: 5.1.0
@ngtools/json-schema: 1.1.0
typescript: 2.5.3
webpack: 3.10.0
Repro steps
- Update npm packages
- Update CLI
- Start app -
ng s
Observed behavior
ERROR in Error: No NgModule metadata found for 'AppModule'.
at NgModuleResolver.resolve (/Users/John/Dev/Javascript/Angular/FRC-TimeTracker/node_modules/@angular/compiler/bundles/compiler.umd.js:20277:23)
at CompileMetadataResolver.getNgModuleMetadata (/Users/John/Dev/Javascript/Angular/FRC-TimeTracker/node_modules/@angular/compiler/bundles/compiler.umd.js:15230:60)
at visitLazyRoute (/Users/John/Dev/Javascript/Angular/FRC-TimeTracker/node_modules/@angular/compiler/bundles/compiler.umd.js:31169:104)
at AotCompiler.listLazyRoutes (/Users/John/Dev/Javascript/Angular/FRC-TimeTracker/node_modules/@angular/compiler/bundles/compiler.umd.js:31137:20)
at AngularCompilerProgram.listLazyRoutes (/Users/John/Dev/Javascript/Angular/FRC-TimeTracker/node_modules/@angular/compiler-cli/src/transformers/program.js:156:30)
at Function.NgTools_InternalApi_NG_2.listLazyRoutes (/Users/John/Dev/Javascript/Angular/FRC-TimeTracker/node_modules/@angular/compiler-cli/src/ngtools_api.js:44:36)
at AngularCompilerPlugin._getLazyRoutesFromNgtools (/Users/John/Dev/Javascript/Angular/FRC-TimeTracker/node_modules/@angular/cli/node_modules/@ngtools/webpack/src/angular_compiler_plugin.js:248:66)
at Promise.resolve.then.then (/Users/John/Dev/Javascript/Angular/FRC-TimeTracker/node_modules/@angular/cli/node_modules/@ngtools/webpack/src/angular_compiler_plugin.js:565:50)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:160:7)
Desired behavior
App run normally
Mention any other details that might be useful (optional)
Application built and ran just fine before update.
Did try rm -rf node_modules and reinstall, no change.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 5
- Comments: 43 (1 by maintainers)
Unbelievable! It works after just editing any “.ts” file.
Update typescript of project to 2.6.2 solved it for me.
npm install --save-dev typescript@2.6.2
.Took sooooo much time to figure out as the solution of deleting cli and cache and reinstalling them was working only partially.
steps:
cd
to project directoryI have the same issue when i update angular 2.x -> 6.x . I delete the package-lock.json and reinstall node_modules, it work fine now
Thanks for reporting this issue. However, you didn’t provide sufficient information for us to understand and reproduce the problem. Please check out our submission guidelines to understand why we can’t act on issues that are lacking important information.
If the problem persists, please file a new issue and ensure you provide all of the required information when filling out the issue template.
This worked for me, Thanks a ton @Albejr, you saved my day.
Same problem as @Albejr tks for the temp workaround
This thinks make my job a special job, it’s pretty like y car not start for a engine problem and y open and close the door and the car start work again. LOL
I had a similar problem, but my problem was the name of the module when I was trying to load the module with lazy load. The first letter was in lowercase.
path/to/projects.module#projectsModule
so I changed it like this and it works:
path/to/projects.module#ProjectsModule
Got the same error, in my case it is caused by an import statement:
import NgModule = core.NgModule;
For instance following code report error when build.
import core = require("@angular/core");
import NgModule = core.NgModule;
@NgModule( {....})
export class AppModule {}
And the error is gone if rewrite the code like below:
import core = require("@angular/core");
@core.NgModule( {....})
export class AppModule {}
What happens if you upgrade typescript to 2.6.0?
@Albejr thank you very much bro!
me too
@Albejr wth?? how i can llive now with this… helps me too! but its looks bad
@Albejr your solution worked for me as well.
Even programming languages works with horoscope magics!!!
For me, I had an APP_INITIALIZER function/factory where the function was not "export"ed. Once I exported the function, it started working again.
OMG i can’t believe @Albejr solution worked for me.
@vapits this solved my problem, excellent !