如何在 codeanywhere IDE 中预览 Angular 应用程序?

Posted

技术标签:

【中文标题】如何在 codeanywhere IDE 中预览 Angular 应用程序?【英文标题】:How to preview angular app in codeanywhere IDE? 【发布时间】:2021-07-29 01:56:34 【问题描述】:

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

【问题讨论】:

【参考方案1】:

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

    请检查您的容器是否已打开并正在运行 请确保您的服务器(angular) 正在运行并且listening on 0.0.0.0 IP 地址。 (如果你在 127.0.0.1 (localhost) 上监听,那么它在 Container 之外是不可用的) 您的服务器可能在不同的端口上运行,请检查您使用的端口是否正确。

请使用以下命令确保上述所有点都匹配编译 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.

【讨论】:

以上是关于如何在 codeanywhere IDE 中预览 Angular 应用程序?的主要内容,如果未能解决你的问题,请参考以下文章

我可以将哪些设置设置为 C++ 的 Codeanywhere 项目配置?

如何在 Codeanywhere.com 上的 Python 中使用 tkinter 模块

如何在 codeanywhere 中配置 React API 代理

如何在 codeanywhere.com 上使用 react native

我如何使用 codeanywhere 片段

如何从 Codeanywhere 查看 PHP 错误日志?