question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ERROR in AppModule is not an NgModule

See original GitHub issue

Please provide us with the following information:

OS?

Windows 7

Versions.

ng --version @angular/cli: 1.0.0-beta.31 node: 7.2.0 os: win32 x64 @angular/common: 2.4.7 @angular/compiler: 2.4.7 @angular/core: 2.4.7 @angular/forms: 2.4.7 @angular/http: 2.4.7 @angular/platform-browser: 2.4.7 @angular/platform-browser-dynamic: 2.4.7 @angular/router: 3.4.7 @angular/cli: 1.0.0-beta.31 @angular/compiler-cli: 2.4.7 @ngtools/webpack: 1.2.9

$ npm list -g --depth=0 C:\Users\Macpro\AppData\Roaming\npm ±- @angular/cli@1.0.0-beta.31 ±- cordova@6.5.0 ±- grunt-cli@1.2.0 ±- http-server@0.9.0 ±- ionic@2.2.1 ±- minimatch@3.0.3 ±- node-uuid@1.4.7 ±- npm@4.2.0 `-- typescript@2.1.6

Repro steps.

I’ve tried to update the angular-cli with these steps: https://github.com/angular/angular-cli#updating-angular-cli

I’ve done global update and local project as well, all good until I try to serve the app - it gives me the below error

The log given by the failure.

$ ng serve

ERROR in AppModule is not an NgModule ERROR in ./src/main.ts Module build failed: TypeError: Cannot read property ‘newLine’ of undefined at Object.getNewLineCharacter (C:\Users\Macpro\Desktop\Test\Angular2\Angular2\CLI\puzzleTest\node_modules\typescript\lib\typescript.js:8062:20) at Object.createCompilerHost (C:\Users\Macpro\Desktop\Test\Angular2\Angular2\CLI\puzzleTest\node_modules\typescript\lib\typescript.js:44978:26) at Object.ngcLoader (C:\Users\Macpro\Desktop\Test\Angular2\Angular2\CLI\puzzleTest\node_modules@ngtools\webpack\src\loader.js:341:33) @ multi webpack-dev-server/client?http://localhost:4200/ ./src/main.ts webpack: Failed to compile.


I also got this “minimatch” errror every time I try to update or install somtehing: npm update -g

npm WARN deprecated minimatch@0.2.14: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue

But as you can see above I have “minimatch@3.0.3” - anyway this is not the problem here

Mention any other details that might be useful.

I’ve tried to update the typescript like I’ve seen on the web but with no success. I also


Thank you for your time!

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:12
  • Comments:43 (1 by maintainers)

github_iconTop GitHub Comments

30reactions
SanderEliascommented, Feb 10, 2017

I got the same problem. On ubuntu 16. But only on the first build: image The only change I made was adding an empty line to the app.module.ts

22reactions
dessalinescommented, Feb 10, 2017

Don’t ask me why, but I think this is a yarn issue. Running

rm -rf node_modules
npm i
ng serve

fixes the problem, but the problem remains if you do yarn instead of npm i.

EDIT: another thing that worked was reinstalling yarn : https://yarnpkg.com/lang/en/docs/install/#linux-tab

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error: AppModule is not an NgModule - angular - Stack Overflow
I found a solution. Change the version of typescript to 2.0.10 I reply for myself and others who are stuck this problem :)....
Read more >
AppModule is not an NgModule | fluin.io blog
If you see the error AppModule is not an NgModule when using the Angular CLI, then the solution is most likely to rollback...
Read more >
Error message Is it missing @NgModule annotation? NG6002
Error message Is it missing @ NgModule annotation? NG6002: Appears NgModule.imports AppModule Angular. Watch later. Share. Copy link.
Read more >
Error: AppModule is not an NgModule - YouTube
angular: Error : AppModule is not an NgModuleThanks for taking the time to learn more. In this video I'll go through your question, ......
Read more >
'formsmodule' does not appear to be an ngmodule class.
After doing so, I'm getting compile error that I completely don't understand. 'SharedModule' does not appear to be an NgModule class.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found