Yaml无效:此处不允许使用映射值

时间:2019-08-01 04:43:35

标签: yaml amazon-elastic-beanstalk

AWS弹性beantalk -

上部署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

2 个答案:

答案 0 :(得分:1)

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

head_width

这是您所提出的YAML:

import cartopy.crs as ccrs
import matplotlib.pyplot as plt
import cartopy.feature as cfeature

east = 15.6562839 # max -180
west = 5.0506635 # max 180
north = 55.3841673 # max 90
south = 47.1113124 # max -90

ax = plt.axes(projection=ccrs.PlateCarree())
ax.set_extent([west, east, south, north])
ax.stock_img()

ax.add_feature(cfeature.COASTLINE)
ax.add_feature(cfeature.BORDERS)

berlin_lon, berlin_lat = 13.388889, 52.516667
aachen_lon, aachen_lat = 6.083611, 50.775556


#https://matplotlib.org/users/annotations_intro.html
ax.annotate('20kg',
            xy=(berlin_lon, berlin_lat),
            xytext=(aachen_lon, aachen_lat),
            arrowprops=dict(arrowstyle="simple",
                            connectionstyle="arc3,rad=-0.4",
                            linewidth=1,
                            ), 
            )

plt.show()

您能发现差异吗?

扰流器:您在option_settings: aws:elasticbeanstalk:container:nodejs: NodeCommand: "node server.compiled.js" 之后放置了一个空格。这使YAML解析器假定option_settings: aws: elasticbeanstalk:container:nodejs: NodeCommand: "node server.compiled.js" 是具有值aws:的映射键。但是,下一行也以映射键(aws:开头)将缩进更多,只有在前一行是没有值的映射键的情况下才允许缩进。

如果删除空格,则将enter image description here "elasticbeanstalk:container:nodejs:"作为映射键,并将下一行作为其值。

答案 1 :(得分:0)

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

Procfile

web: node index.js

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