ERROR in AppModule is not an NgModule No NgModule metadata found for ‘AppModule’.

Angularjs2’s environmental problems have been solved for a long time.
Baidu’s answer is also a variety of also can not solve my problems.
Fortunately, these days after constant testing finally to solve.
ERROR in AppModule is not an NgModule
ERROR in ./src/main.ts
Module build failed: TypeError: Always read the property ‘newLine of undefined
at the Object. The getNewLineCharacter (d: \ web \ myNg \ ng2 \ node_modules \ typescript \ lib \ typescript js: 8062:20)
at the Object. The createCompilerHost (d:\web\myNg\ng2\node_modules\typescript\lib\typescript.js:44978:26)
at Object.ngcLoader (d:\web\myNg\ng2\node_modules@ngtools\webpack\src\loader.js:338:33)
@ multi webpack-dev-server/client?http://localhost:4200 ./src/main.ts
ERROR in ./src/polyfills.ts
Module build failed: TypeError: Always read the property ‘newLine of undefined
at the Object. The getNewLineCharacter (d: \ web \ myNg \ ng2 \ node_modules \ typescript \ lib \ typescript js: 8062:20)
at the Object. The createCompilerHost (d:\web\myNg\ng2\node_modules\typescript\lib\typescript.js:44978:26)
at Object.ngcLoader (d:\web\myNg\ng2\node_modules@ngtools\webpack\src\loader.js:338:33)
@ multi ./src/polyfills.ts
webpack: Failed to compile.
This error is due to a local Typescript version conflict. But I don’t know why NPM is doing this. The web site says its mechanism is not supposed to cause version conflicts. It hasn’t been studied.
first:
$ npm ls typescript
Enter this command to see the Typescript version and dependencies of your project.
Two different versions have been found in various places.
Angular \ CLi relies on 2.1.6, which is automatically generated, so you can’t go to the node_module to find package.json. Can’t change. To give up.
[email protected] d: \ web \ myNg \ ng2
– – @ presents/[email protected] – & gt; D :\web\myNg\ node_modules.1.0.0-rc-1 @angular\cli
| ± -@angular /[email protected]
| | ± -@angular /[email protected]
| |>0 -- [email protected] deduped extraneous>1>2 [email protected] extraneous
| ± -@angular /[email protected]
| | ± [email protected]
|>0>1 -- [email protected] extraneous>3 [email protected] extraneous
>4 ±- @ngtools/[email protected]
| |-- [email protected] extraneous |[email protected]
‘– [email protected]
Then the other 2.0.10 is configured in the project’s package.json. This is angular/ CLI generated, but it’s in our own project, so it’s easy to change typescript to the angular/ CLI dependent version.
“Typescript” : “~2.0.0”
“change this to
” typescript “:” ~2.1.0 “
~ means that NPM automatically downloads the nearest smaller version. For example, it’s 2.1.6 on my computer. In this case, the Angular/CLI dependencies themselves are completely consistent.
again
$ npm ls typescript
Found that the version is consistent.
[email protected] d: \ web \ myNg \ ng2
– – @ presents/[email protected] – & gt; D :\web\myNg\ node_modules.1.0.0-rc.1@@angular\cli
| -- [email protected][email protected] -> D: \ web \ myNg \ ng2 \ node_modules 2.1.6 @ typescript
$ ng serve
** NG Live Development Server is running on http://localhost:4200 **
Hash: b21dc5aadbb6f2b69213
Time: 10251ms
chunk {0} polyfills.bundle.js, polyfills.bundle.js.map (polyfills) 158 kB {4} [initial] [rendered]
chunk {1} main.bundle.js, Rendered]
chunk {3} vendor.js.map (main) 3.14 kB {3} [initial] [rendered]
chunk {2} styles. funds. js (styles) 9.84 kB {4} [initial] Version2.6 MB [initial] [br> chunk {4} invitation.js, ininvitation.js map (ininvitation.js) 0 bytes [entry] [rendered]
webpack: Compiled.
Get things done. I will make a note here in the hope that I can help others I meet later. After all, it’s such a waste of time.
Also, remember to use CNPM install when installing the environment. The native NPM Install will report an error because Node-Sass is blocked.
The original link: https://blog.csdn.net/yaerfeng/article/details/62610510

Read More: