0

codeanywhere或中运行 Angular 应用程序时cloud9,我们无法预览已编译的 Angular 或任何其他 Web 应用程序。我们收到空白屏幕或一些错误消息。

4

1 回答 1

1

要预览它,我们必须进行以下检查

  1. 请检查您的容器是否已打开并正在运行
  2. 请确保您的服务器(角度)正在运行和listening on 0.0.0.0IP 地址。(如果您在 127.0.0.1 (localhost) 上收听,那么它在 Container 外部不可用
  3. 您的服务器可能在不同的端口上运行,请检查您使用的端口是否正确。

请使用下面的命令来确保上述所有点都与编译 Angular 应用程序相匹配。

ng serve --host 0.0.0.0 --port 4201 --disable-host-check

这里端口号 4201 是我的选择,请随意选择。

现在 codeanywhere IDE 已准备好在外部查看。在某些情况下,您可能无法在浏览器中查看应用程序的预览 URL。如果是这样,我们必须找到预览网址。让我们看看如何在下面构建它:

https://port-4201-containerName-username.preview.codeanywhere.com/

请根据您的 IDE 自行替换下面提到的关键字

  • 4201是你的端口号
  • containerName是您的容器的名称(项目环境)
  • 用户名是codeanywhere用户名

This is not only for angular and applicable for all the web apps. Angular is an example here.

于 2021-05-06T17:43:20.990 回答