angular-cli icon indicating copy to clipboard operation
angular-cli copied to clipboard

ERROR in AppModule is not an NgModule

Open tHesTx opened this issue 9 years ago • 43 comments

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/[email protected] +-- [email protected] +-- [email protected] +-- [email protected] +-- [email protected] +-- [email protected] +-- [email protected] +-- [email protected] `-- [email protected]

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 [email protected]: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue

But as you can see above I have "[email protected]" - 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!

tHesTx avatar Feb 10 '17 11:02 tHesTx

I ran into the same issue, this fixed it for me, see reference here: https://github.com/angular/angular-cli/issues/6425

Here are the versions I used to get it running:

yarn: 1.1.0, angular-cli: 1.4.7, typescript: 2.2.2

sanyooh avatar Jul 18 '18 11:07 sanyooh

I ran into the same issue myself with Yarn, using this package.lock =>

 "dependencies": {
    "@angular/animations": "4.4.7",
    "@angular/cdk": "2.0.0-beta.10",
    "@angular/common": "^4.0.0",
    "@angular/compiler": "^4.0.0",
    "@angular/compiler-cli": "^4.2.2",
    "@angular/core": "^4.0.0",
    "@angular/forms": "^4.0.0",
    "@angular/http": "^4.0.0",
    "@angular/material": "2.0.0-beta.10",
    "@angular/platform-browser": "^4.0.0",
    "@angular/platform-browser-dynamic": "^4.0.0",
    "@angular/platform-server": "^4.2.2",
    "@angular/router": "^4.0.0",
    "@ngui/tooltip": "^0.5.1",
    "@ngx-translate/core": "^6.0.0",
    "@ngx-translate/http-loader": "^0.1.0",
    "@types/intro.js": "^2.4.3",
    "@types/protractor-http-mock": "0.0.33",
    "@types/underscore": "^1.8.1",
    "aes-js": "3.1.0",
    "angular2-fontawesome": "~0.9.0",
    "angular2-oauth2": "^1.3.10",
    "angular2-tooltip": "^3.1.0",
    "core-js": "^2.4.1",
    "crypto-js": "3.1.9-1",
    "font-awesome": "~4.7.0",
    "intro.js": "^2.9.3",
    "jquery": "^3.2.1",
    "jqueryui": "^1.11.1",
    "jsuri": "^1.3.1",
    "localize-router": "^0.7.0",
    "ng2-accordion": "0.0.15",
    "ng2-selectize": "^1.0.1",
    "ngx-bootstrap": "^1.7.1",
    "ngx-tooltip": "0.0.9",
    "npm": "^5.8.0",
    "rxjs": "^5.1.0",
    "selectize": "^0.12.4",
    "underscore": "^1.8.3",
    "zone.js": "^0.8.4"
  },
  "devDependencies": {
    "@angular/cli": "1.2.6",
    "@angular/compiler-cli": "^4.0.0",
    "@types/jasmine": "2.5.38",
    "@types/node": "~6.0.60",
    "codelyzer": "~2.0.0",
    "jasmine-core": "~2.5.2",
    "jasmine-spec-reporter": "~3.2.0",
    "karma": "~1.4.1",
    "karma-chrome-launcher": "~2.1.1",
    "karma-cli": "~1.0.1",
    "karma-coverage-istanbul-reporter": "^0.2.0",
    "karma-jasmine": "~1.1.0",
    "karma-jasmine-html-reporter": "^0.2.2",
    "ng-mock-e2e": "~0.1.3",
    "protractor": "~5.1.0",
    "protractor-http-mock": "^0.9.2",
    "string-replace-loader": "^2.1.1",
    "ts-node": "~2.0.0",
    "tslint": "~4.5.0",
    "typescript": "2.2.0"
  }

Which produced the same error as outlined above.

In my case the problem was the installed Typescript version that seems to not be compatible with the @angular/cli version

After upgrading to Typescript 2.3.4, I got it working fine, and could use AOT compiler with yarn

Fred-JulieDesk avatar Nov 21 '18 14:11 Fred-JulieDesk

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.