简体   繁体   English

运行 `ng update @angular/cli @angular/core` 后 `ng serve` 出错,无法为 Angular 项目提供服务

[英]Error from `ng serve` after running `ng update @angular/cli @angular/core` and unable to serve Angular project

In my Angular project, I was having errors while trying to build a docker image.在我的 Angular 项目中,我在尝试构建 docker 映像时遇到错误。 I used ng update @angular/cli @angular/core and was able to resolve that error, and now I'm able to create a docker container of my project that is served.我使用了ng update @angular/cli @angular/core并且能够解决该错误,现在我能够为我的项目创建一个 docker 容器。 However, now I cannot serve my project with ng serve because I get the following error:但是,现在我无法使用ng serve为我的项目提供ng serve因为我收到以下错误:

An unhandled exception occurred: compiler.getInfrastructureLogger is not a function

getInfrastructureLogger is NOT a function I created, I'm assuming it's coming from a node mod. getInfrastructureLogger不是我创建的函数,我假设它来自节点 mod。 I've tried deleting the node_mod folder and install them again with npm install , but I still get the same error.我已经尝试删除 node_mod 文件夹并使用npm install重新安装它们,但我仍然遇到相同的错误。 I've tried cleaning my npm cache and I still get the error.我已经尝试清理我的 npm 缓存,但仍然出现错误。

I went back a couple of commits (to before I ran ng update @angular/cli @angular/core ) and then I'm able to run ng serve with no errors, but am then unable to create my docker images.我返回了几次提交(在我运行ng update @angular/cli @angular/core ),然后我可以运行ng serve没有错误,但是我无法创建我的 docker 图像。 I need to be able to use containers, so I have to use ng update @angular/cli @angular/core .我需要能够使用容器,所以我必须使用ng update @angular/cli @angular/core But I also want to be able to serve my project as a standalone (plus it better for developing).但我也希望能够将我的项目作为一个独立的项目(加上它更适合开发)。

Does anyone have any advise on this error?有没有人对这个错误有任何建议? Where it's coming from?它来自哪里? Solutions?解决方案? I would really appreciate it.我真的很感激。 Thanks for any help you can give.谢谢你提供的所有帮助。

***To specify, I used ng update @angular/cli @angular/core --force it was the only for me to run that command. ***要指定,我使用了ng update @angular/cli @angular/core --force它是我运行该命令的唯一方法。

My project is Angular 8, node node version 12.14.我的项目是 Angular 8,节点节点版本 12.14。

The update in angular versions or one of the dependencies caused this error.角度版本或依赖项之一的更新导致此错误。 We could help more if we knew what version of Angular you were coming from and what version you were updating to.如果我们知道您来自哪个版本的 Angular 以及您要更新到哪个版本,我们可以提供更多帮助。

First, if you're upgrading to the latest stable Angular version (8.x), make sure you have node 10.9 or later installed.首先,如果您要升级到最新的稳定 Angular 版本 (8.x),请确保安装了 node 10.9 或更高版本。

Regardless, the Angular Upgrade Guide is an awesome tool that allows you to input the version you're coming from and the version you're going to and it will give you step-by-step instructions as to what you need to do in order to upgrade your angular app.无论如何, Angular Upgrade Guide是一个很棒的工具,它允许您输入您来自的版本和您将要使用的版本,它将为您提供有关您需要执行的操作的分步说明升级您的角度应用程序。 Try upgrading one major version at a time following these instructions.尝试按照这些说明一次升级一个主要版本。 It almost always resolves my problems.它几乎总能解决我的问题。

Please note: It's better to upgrade one version at a time请注意:最好一次升级一个版本

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM