无服务器错误 - 没有文件匹配包括/排除模式

Serverless error - No file matches include / exclude patterns

我正在尝试使用 python 进行一些框架部署。这是我的 serverless.yaml

我的文件夹结构是

serverless-test
|_lambdas
|____handler.py
|_layers
|____common
|_________somefunction.py
service: serverless-test

frameworkVersion: '2'

provider:
  name: aws
  runtime: python3.8
  lambdaHashingVersion: 20201221

  stage: test
  region: us-west-2

functions:
  hello:
    handler: lambdas/handler.hello

这很好用。现在,只要我添加一层,就会出现以下错误

No file matches include / exclude patterns

service: serverless-test

frameworkVersion: '2'

provider:
  name: aws
  runtime: python3.8
  lambdaHashingVersion: 20201221

  stage: test
  region: us-west-2

functions:
  hello:
    handler: lambdas/handler.hello
    layers:
      - {Ref: CommonLambdaLayer}

layers:
  common:
    path: layers/common
    name: common-module
    description: common set of functions

我还尝试添加包含和排除模式。但是并没有解决我的问题

service: serverless-test

frameworkVersion: '2'

provider:
  name: aws
  runtime: python3.8
  lambdaHashingVersion: 20201221

  stage: test
  region: us-west-2

package:
  individually: true
  exclude: 
    - ./**
  include:
    - ./lambdas/**

functions:
  hello:
    handler: lambdas/handler.hello
    layers:
      - {Ref: CommonLambdaLayer}

layers:
  common:
    path: layers/common
    name: common-module
    description: common set of functions
    package:
      include:
        - ./**

我也试过非常具体

service: serverless-test

frameworkVersion: '2'

provider:
  name: aws
  runtime: python3.8
  lambdaHashingVersion: 20201221

  stage: test
  region: us-west-2

package:
  individually: true
  exclude: 
    - ./**

functions:
  hello:
    handler: lambdas/handler.hello
    layers:
      - {Ref: CommonLambdaLayer}
    package:
      exclude:
        - ./**
      include:
        - ./lambdas/handler.py

layers:
  common:
    path: layers/common
    name: common-module
    description: common set of functions
    package:
      exclude:
        - ./**
      include:
        - ./layers/common/somefunction.py

我遇到了同样的问题并找到了这个答案here:

serverless is checking those files against the patterns specified in the root package:exclude and because./** matches every file and the include-pattern./functions/**/* matches none, no files are actually included in the layer, which causes the error.

只需尝试从排除项中删除 ./**

package:
  individually: true
  exclude: 
    - ./** # <-- remove this!