Node.js CircleCI中的YAML配置文件分析错误

Node.js CircleCI中的YAML配置文件分析错误,node.js,github,yaml,circleci,Node.js,Github,Yaml,Circleci,我一直在Github存储库上试用CircleCI,但它的配置文件中存在一些问题。我查看了Node.js管道的模板,并从中设计了自己的测试。它所要做的就是安装Node.js,检查其版本,并安装最新的npm包。提交文件后,CircleCI告诉我我的构建失败了。当我查看日志时,我注意到YAML配置文件本身没有正确解析。我在谷歌上翻来翻去,找不到任何有用的信息,对我的代码结构做一些基本的调整似乎也没什么帮助 这是我的配置文件: version: 2.0 jobs: build: docker

我一直在Github存储库上试用CircleCI,但它的配置文件中存在一些问题。我查看了Node.js管道的模板,并从中设计了自己的测试。它所要做的就是安装Node.js,检查其版本,并安装最新的npm包。提交文件后,CircleCI告诉我我的构建失败了。当我查看日志时,我注意到YAML配置文件本身没有正确解析。我在谷歌上翻来翻去,找不到任何有用的信息,对我的代码结构做一些基本的调整似乎也没什么帮助

这是我的配置文件:

version: 2.0
jobs:
  build:
    docker:
      # specify the version you desire here
      - image: circleci/node:12.15.0

      # Specify service dependencies here if necessary
      # CircleCI maintains a library of pre-built images
      # documented at https://circleci.com/docs/2.0/circleci-images/
      - image: circleci/mongo:3.4.4

    working_directory: ~/repo

    steps:
     - checkout
  - run:
          name: "Update files"
          command: |
            curl -sSL "https://nodejs.org/dist/v12.15.0/node-v12.15.0.tar.gz"
            npm @latest -g
  - run:
        name: "Check current version of Node.js"
        command: node -v
以下是日志文件:

#!/bin/sh -eo pipefail
#!/bin/sh -eo pipefail
# Unable to parse YAML
# while parsing a block mapping
#  in 'string', line 7, column 3:
#       build:
#       ^
# expected <block end>, but found '-'
#  in 'string', line 21, column 3:
#       - run:
#       ^
# 
# -------
# Warning: This configuration was auto-generated to show you the message above.
# Don't rerun this job. Rerunning will have no effect.
false
#/垃圾箱/垃圾箱-eo管道故障
#!/垃圾箱/垃圾箱-eo管道故障
#无法分析YAML
#在分析块映射时
#在“字符串”第7行第3列中:
#建造:
#       ^
#应为,但找到“-”
#在“字符串”第21行第3列中:
#-运行:
#       ^
# 
# -------
#警告:此配置是自动生成的,用于显示上述消息。
#不要重新运行此作业。重新运行不会产生任何影响。
假的

yaml
对缩进/空格数非常严格。在您的例子中,问题在于步骤的缩进

version: 2.0
jobs:
  build:
    docker:
      # specify the version you desire here
      - image: circleci/node:12.15.0

      # Specify service dependencies here if necessary
      # CircleCI maintains a library of pre-built images
      # documented at https://circleci.com/docs/2.0/circleci-images/
      - image: circleci/mongo:3.4.4

    working_directory: ~/repo

    steps:
      - checkout
      - run:
            name: "Update files"
            command: |
              curl -sSL "https://nodejs.org/dist/v12.15.0/node-v12.15.0.tar.gz"
              npm @latest -g
      - run:
            name: "Check current version of Node.js"
            command: node -v

不是更少或更多,我们需要为特定块遵循相同的缩进。如果您正在使用IDE或编辑器,最好在IDE或编辑器中使用
yaml
插件支持