首页 > 解决方案 > 如何为 nodejs Google App Engine 项目制作基本的 app.yaml 文件

问题描述

我正在为谷歌应用引擎制作一个 nodejs 项目。测试一切正常,应用程序正常运行,但是当提示通过 部署我的代码文件时gcloud app deploy,我收到以下错误:

错误:需要 app.yaml(或 appengine-web.xml)文件才能将此目录部署为 App Engine 应用程序

我以前从未使用过yaml。基本 yaml 文件的内容应该是什么样子才能解决此问题并部署我的代码?

标签: google-app-enginegoogle-cloud-platform

解决方案


正如您在https://docs.ansible.com/ansible/latest/reference_appendices/YAMLSyntax.html中看到的那样,YAML 的基础很简单,如下所示:

字典 -key: value


列表/数组 (1) -
name: - item1 - item2
列表/数组 (2) -name: ["item1", "item2"]
嵌套属性 (1) -
nest: nestedKey: value nestedList: - item1 - item2

关于您指定的特定 YAML 文件,请阅读https://cloud.google.com/appengine/docs/flexible/java/configuring-your-app-with-app-yaml了解更多信息。
这是该页面中的一个简单示例:

runtime: java
env: flex

handlers:
- url: /.*
  script: this field is required, but ignored

推荐阅读