Skip to main content

创建应用程序

要快速建立自己的 Backstage 项目,可以创建一个 Backstage 应用程序。

Backstage应用程序是一个单核设置,其中包括lerna其中包括在自己的环境中运行 Backstage 所需的一切。

如果您打算为 Backstage 项目贡献插件、新功能或错误修复,您可能需要阅读贡献者指南。

创建应用程序

要创建 Backstage 应用程序,您需要有 Node.js激活的 LTS 版本已安装。

Backstage 提供了一个创建新应用程序的实用工具。 它可以指导您完成初始设置,选择应用程序的名称和后端数据库。 数据库选项有 SQLite 或 PostgreSQL,后者需要您设置一个单独的数据库实例。 如果有疑问,请选择 SQLite,但不用担心选择问题,以后很容易更改!下面是一个例子教程为它。

运行创建应用程序软件包的最简单方法是使用npx:

npx @backstage/create-app@latest

这将在当前文件夹内创建一个新的 Backstage 应用程序。 应用程序文件夹的名称为提示时提供的名称。

create app

在该目录中,它将生成运行应用程序所需的所有文件和文件夹结构。

一般文件夹结构

以下是创建应用程序时生成的文件和文件夹的简化布局。

app
├── app-config.yaml
├── catalog-info.yaml
├── lerna.json
├── package.json
└── packages
  ├── app
   └── backend
  • app-config.yaml: Main configuration file for the app. See Configuration for more information. * catalog-info.yaml: Catalog Entities descriptors. See Descriptor Format of Catalog Entities to get started. * lerna.json: Contains information about workspaces and other lerna configuration needed for the monorepo setup. * package.json: Root package.json for the project. Note: Be sure that you don't add any npm dependencies here as they probably should be installed in the intended workspace rather than in the root. * packages/: Lerna leaf packages or "workspaces". Everything here is going to be a separate package, managed by lerna. * packages/app/: An fully functioning Backstage frontend app, that acts as a good starting point for you to get to know Backstage. * packages/backend/: We include a backend that helps power features such as [Authentication](https://backstage.io/docs/a

故障排除

创建应用程序 "命令并非总能按预期运行,这里收集了一些常见问题和解决方案。

找不到 "文件保存 "的任何版本

您可能会遇到以下错误信息:

Couldn't find any versions for "file-saver" that matches "eligrey-FileSaver.js-1.3.8.tar.gz-art-external"

这可能是因为您全局配置了 npm 代理,从而破坏了material-table这是一个已知的问题,目前正在material-table但现在您可以使用以下方法解决这个问题:

NPM_CONFIG_REGISTRY=https://registry.npmjs.org npx @backstage/create-app

找不到 Python 可执行文件 "python"

如果没有安装 Python,安装过程也可能会失败。 Python 在大多数系统中都已可用,但如果没有安装,您可以使用以下方法,例如这里进行安装。

无法执行 yarn install 命令

用以下命令在系统中安装 Yarnnpm install --global yarn或更多详细信息,请参阅先决条件.

运行应用程序

安装完成后,您可以打开应用程序文件夹并启动应用程序。

cd my-backstage-app
yarn dev

yarn dev命令会将前端和后端作为单独的进程运行(名为[0][1]命令运行完成后,应该会打开一个显示应用程序的浏览器窗口。 如果没有,可以打开浏览器直接导航到前端,网址是http://localhost:3000.

现在你可以自由地安装自己的 Backstage 软件了!

随着您对应用程序的使用经验越来越丰富,今后您可以只运行前端,使用yarn start在一个窗口中,后端用yarn start-backend在另一个窗口中。