ERROR in AppModule is not an NgModule
See original GitHub issuePlease 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:
- Created 7 years ago
- Reactions:12
- Comments:43 (1 by maintainers)
I got the same problem. On ubuntu 16. But only on the first build:
The only change I made was adding an empty line to the app.module.ts
Don’t ask me why, but I think this is a yarn issue. Running
fixes the problem, but the problem remains if you do
yarn
instead ofnpm i
.EDIT: another thing that worked was reinstalling yarn : https://yarnpkg.com/lang/en/docs/install/#linux-tab