【问题标题】:Invalid Yaml: mapping values are not allowed here无效的 Yaml:此处不允许映射值
【发布时间】:2019-12-09 15:12:33
【问题描述】:

AWS elastic beanstalk 上部署 react 应用程序时,谁能帮我找出以下错误 -

2019-08-01 04:37:21    ERROR   The configuration file .ebextensions/nodecommand.
config in application version app-5466-190801_100700 contains invalid YAML or JS
ON. YAML exception: Invalid Yaml: mapping values are not allowed here
 in "<reader>", line 3, column 16:
    option_settings:
                   ^
, JSON exception: Invalid JSON: Unexpected character (/) at position 0.. Update
the configuration file.
2019-08-01 04:37:21    ERROR   Failed to deploy application.

以下是我的 nodecommand.config 文件 -

option_settings: 
  aws: elasticbeanstalk:container:nodejs:  
    NodeCommand: "node server.compiled.js"

更新 -

我按照此链接在 AWS 弹性 beantalk 上部署 React 应用程序并遇到上述错误 -

https://medium.com/@wlto/how-to-deploy-an-express-application-with-react-front-end-on-aws-elastic-beanstalk-880ff7245008

【问题讨论】:

    标签: yaml amazon-elastic-beanstalk


    【解决方案1】:

    这是链接教程中显示的内容:

    option_settings:
      aws:elasticbeanstalk:container:nodejs:
        NodeCommand: "node server.compiled.js"
    

    这是您问题中的 YAML:

    option_settings: 
      aws: elasticbeanstalk:container:nodejs:  
        NodeCommand: "node server.compiled.js"
    

    你能看出区别吗?

    剧透:你在aws: 后面加了一个空格。这会导致 YAML 解析器假定 aws: 是一个映射键,其值为 "elasticbeanstalk:container:nodejs:"。但是,同样以映射键 (NodeCommand) 开头的下一行缩进更多,只有在上一行是没有值的映射键时才允许缩进。

    如果去掉空格,它correctly parsesaws:elasticbeanstalk:container:nodejs作为映射键,下面一行作为它的值。

    【讨论】:

    • 非常感谢@Jordan 的回复,让我们修复并尝试一下。
    • @SachinVairagi 你解决了这个问题吗?我遇到了同样的错误。但是相同的配置(aws: 和行的其余部分之间没有空格)以前对我有用。现在我遇到了和你一样的问题。
    【解决方案2】:

    我实际上并没有解决问题。我发现这个文档 [1] 说因为我的环境使用的是 Amazon Linux 2,所以不推荐使用 ebextensions。 (但我的一些 ebextensions 仍在工作。我对此一无所知)。相反,建议使用 Buildfile、Procfile 和平台挂钩。因此,我创建了一个Procfile,内容如下,让Node服务器运行,命令node index.js

    过程文件

    web: node index.js
    

    [1]https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/platforms-linux-extend.html

    【讨论】:

      猜你喜欢
      • 2019-10-27
      • 1970-01-01
      • 2016-07-13
      • 1970-01-01
      • 1970-01-01
      • 2021-03-15
      • 2014-12-13
      • 2019-08-16
      • 2012-06-13
      相关资源
      最近更新 更多