大佬教程收集整理的这篇文章主要介绍了【Angular学习】Angular4 ng serve报错:ERROR in AppModule is not an NgModule解决方法,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
出现这个错误的原因是angular/cli自己依赖的那个版本和本地ts版本不一致的问题,ts版本过高会出现这个错误。
第一步:卸载全局的ts
npm uninstall -g typescript
第二步:安装2.2.2版本的ts
npm install -g typescript@2.2.2
第三步:查看ts版本是否安装成功
tsc -v
第四步:修改package.json文件中的typescript的版本为~2.2.2
第五步:卸载node库
rimraf node_modules
第六步:重下载node库
cnpm install
第七步:查看项目的typescript版本和依赖,发现两个版本一致了。
npm ls typescrip
+-- @angular/cli@1.6.7 -> E:\07.技术研究\01 Angular\onlineproduct\node_modules\_@angular_cli@1.6.7@@angular\cli
| +-- @angular-devkit/build-optimizer@0.0.42
| | `-- typescript@2.6.2
| `-- @scheR_25_11845@atics/angular@0.1.17
| `-- typescript@2.6.2
`-- typescript@2.6.2 extraneous
第八步:启动项目
ng serve
以上是大佬教程为你收集整理的【Angular学习】Angular4 ng serve报错:ERROR in AppModule is not an NgModule解决方法全部内容,希望文章能够帮你解决【Angular学习】Angular4 ng serve报错:ERROR in AppModule is not an NgModule解决方法所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。