即使我指定了一个,Serverless也无法读取阶段的默认值

时间:2018-12-12 02:37:57

标签: serverless-framework

您好,当我尝试serverless config时返回错误Trying to populate non string value into a string for variable ${opt:stage}. Please make sure the value of the property is a string.。但是,在我的yml文件中,我为stage指定了默认值:

 service: ''
    custom:
      prefixName: ''
      basePath: ''
      stagesPath: '${self:custom.basePath}config/stages'
      env: ${file(${self:custom.stagesPath}/${self:provider.stage}/env.yml)}
      baseUrl: ''
      warmup:
        schedule: 'cron(0/5 * ? * MON-FRI *)' # Run WarmUP every 5 minutes Mon-Fri
        prewarm: true # Run WarmUp immediately after a deployment
      prune:
        automatic: true
        number: 10
      appSync:
        - ${file(${self:custom.stagesPath}/${self:provider.stage}/appsyncUnaMe.yml)}
        # - ${file(${self:custom.stagesPath}/${self:provider.stage}/appsyncUnaCloudFeeds.yml)}
    provider:
      name: aws
      runtime: nodejs8.10
      role:  ${self:custom.env.role}
      stage: ${opt:stage, 'dev'}
      region: ${self:custom.env.region}
      vpc: ${self:custom.env.vpc}
      profile: ${self:custom.env.profile}
      environment: 
        APPSYNC_UNAME_API_X_API_KEY: ${opt:appsyncKey}
        APPSYNC_UNAME_API_X_URI: ${opt:appsyncUri}
        STAGE_NAME: ${opt:stage, 'dev'}
        SERVICE_NAME: ${self:custom.prefixName}
      timeout: 10
      deploymentBucket: ${self:custom.env.deploymentBucket}
      versionFunctions: false
    package:
      individually: true
      exclude:
        - ".*/**"
    plugins:
      # - serverless-webpack
      - serverless-plugin-warmup
      - serverless-prune-plugin
      - serverless-appsync-plugin
      - serverless-offline

    functions:
      ${file(${self:custom.stagesPath}/${self:provider.stage}/resolvers1.yml)}

操作系统:darwin      节点版本:8.11.1      无服务器版本:1.27.3

为什么显示此错误?

1 个答案:

答案 0 :(得分:0)

您错过了另一个。

environment:
  STAGE_NAME: ${opt:stage}