Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ServerlessError: No file matches include / exclude patterns when using Layers #240

Closed
WeaponizedLego opened this issue Jul 8, 2021 · 18 comments · Fixed by #243
Closed

Comments

@WeaponizedLego
Copy link

WeaponizedLego commented Jul 8, 2021

Im experiencing No FIle Matches include / exclude patterns when using the new AWS Lambda layers

here is the last part of the logs

serverless: Packaging service...
Serverless: Excluding development dependencies...
Serverless: Excluding development dependencies...
Serverless: Excluding development dependencies...
 
 Serverless Error ----------------------------------------
 
  ServerlessError: No file matches include / exclude patterns
      at /Users/glen/_code/ts-ooono-backend/node_modules/serverless/lib/plugins/package/lib/packageService.js:263:13
      at processTicksAndRejections (node:internal/process/task_queues:96:5)
      at async /Users/glen/_code/ts-ooono-backend/node_modules/serverless/lib/plugins/package/lib/packageService.js:91:9
      at async Promise.all (index 2)
      at async Package.packageService (/Users/glen/_code/ts-ooono-backend/node_modules/serverless/lib/plugins/package/lib/packageService.js:95:5)
 
  Get Support --------------------------------------------
     Docs:          docs.serverless.com
     Bugs:          github.com/serverless/serverless/issues
     Issues:        forum.serverless.com
 
  Your Environment Information ---------------------------
     Operating System:          darwin
     Node Version:              16.0.0
     Framework Version:         2.47.0 (local)
     Plugin Version:            5.4.0
     SDK Version:               4.2.3
     Components Version:        3.12.0

and this is my layers and plugins

##
## Package settings
##
package:
  excludeDevDependencies: true
  individually: true
  patterns:
    - '!node_modules'
    - '!layers'

##
## Serverless plugins
## TODO: figure out how to have serverless-plugin-typescript in and still deploy as it doesn't build without it
plugins:
  - serverless-plugin-typescript
  - serverless-offline

##
## Layers
##
layers:
  NodeModules:
    path: layers
#    name: NodeModules
    name: ${sls:stage}-NodeModules
    compatibleRuntimes:
      - nodejs14.x
    package:
      patterns:
        - '**/**'
    description: ---
    retain: false # Delete layers once a new one of same name is uploaded

##
## FUNCTIONS
##
functions:
  # GET /hello
  hello:
    handler: ./src/functions/helloworld/index.handler
    events: # The events that trigger this function
      - http:
          path: ts-ooonoBackend/helloworld
          method: get
    layers:
      - { Ref: NodeModulesLambdaLayer }
    package:
      patterns:
        - 'src/functions/helloworld/**'
  goodbye:
    handler: ./src/functions/goodbye/index.handler
    events: # The events that trigger this function
      - http:
          path: ts-ooonoBackend/goodbye
          method: post
    layers:
      - { Ref: NodeModulesLambdaLayer }
    package:
      patterns:
        - 'src/functions/goodbye/**'
@medikoo
Copy link
Contributor

medikoo commented Jul 23, 2021

Will be fixed with #243

@pgrzesik
Copy link

pgrzesik commented Sep 3, 2021

After doing research as part of serverless/serverless#9873 I've realised that layers are generally not supported by this plugin so this issue should still be open.

The general problem here lies in the fact that when packaging files for layers, layer.path property is used as a prefix https://github.com/serverless/serverless/blob/f096440440dfb2339b4fd1ae1ecbca3b59fb4805/lib/plugins/package/lib/packageService.js#L272 however, the logic in the plugin changes the serviceDir to point to .build directory, which means that in most scenarios nothing will be available under serviceDir/<layer.path>.

@abdullahmonoar
Copy link

@pgrzesik any workarounds you know of other than webpacking the ts files ourselves?

@pgrzesik
Copy link

Hello @abdullahmonoar - the only workaround I know is switching to serverless-webpack or serverless-jetpack :(

@alexandrubese
Copy link

I can also confirm it works by using serverless-jetpack

@alexandrubese
Copy link

Any timeframe for the issue create above ^ ?

@medikoo
Copy link
Contributor

medikoo commented Oct 26, 2021

@alexandrubese PR's welcome!

@raiseandfall
Copy link

@medikoo this looks old, but that seems to be addressing the issue: #128

@medikoo
Copy link
Contributor

medikoo commented Jan 14, 2022

@raiseandfall great thanks for pointing. I've reached out to author of the PR to eventually update it so it's in sync with master

@mmeyers-xomly
Copy link
Contributor

mmeyers-xomly commented Mar 19, 2022

Since there wasn't any movement on this from the original author, I updated #128 and submitted it again which fixes this issue #267

@medikoo if you could take a look, I'd love to get this merged so layers work :) Thanks!

@mmeyers-xomly
Copy link
Contributor

So the above PR fixes part of the issue, but not fully. It seems this only helps if the thing you want to put in a layer is something that would be packaged by this plugin. However, if it's an external file that wouldn't be included in the TS build, this is still broken with the same error.

@micheleangioni
Copy link

We've also been hit by this problem, any update?

@micheleangioni
Copy link

It seems we have the PR: #267

@medikoo medikoo closed this as completed Apr 4, 2022
@tachang
Copy link

tachang commented May 6, 2023

So the above PR fixes part of the issue, but not fully. It seems this only helps if the thing you want to put in a layer is something that would be packaged by this plugin. However, if it's an external file that wouldn't be included in the TS build, this is still broken with the same error.

I just ran into this and feel like it the commit needs to be reverted. I'm not sure exactly what case allows it to succeed. Is it checking for patterns: include because that is deprecated in serverless v3.

@leonardoviada
Copy link

@tachang any clue on how to tackle the problem in some way?
I have a module in src/layer/shared/nodejs/node_modules/myd-api-utils/src/index.ts
Locally everything works just fine but I cannot deploy it since it breaks during the CI process

@walshe
Copy link

walshe commented Aug 4, 2023

@tachang any clue on how to tackle the problem in some way? I have a module in src/layer/shared/nodejs/node_modules/myd-api-utils/src/index.ts Locally everything works just fine but I cannot deploy it since it breaks during the CI process

same here

@tttaisgt
Copy link

image the error still there 😢

@cwbuecheler
Copy link

cwbuecheler commented Jan 25, 2024

Still seeing this error as of January 2024. Take the layer out of serverless.yml and the plugin works fine. Put the layer back in, and I get the same error reported above. Layer code in the YML looks like this:

layers:
  shared:
    name: hcapps-file-xfer-shared
    path: layers/shared
    description: Shared functionality for file transfer system
    compatibleRuntimes:
      - nodejs18.x
    compatibleArchitectures:
      - x86_64
    retain: false

I don't see anything in here that should be considered weird.

We've written our own build system for using TS with serverless but I was really hoping to ditch that and use the plugin. We make extensive use of shared layers though, so this is kind of important. I'll admit I could be screwing something up, but at this point I feel like I've tried every reasonable config option (and again, it works fine with the functions - it's just the layer that breaks)

Edit to add: there is nothing in /layers except a file called shared.ts

harigel added a commit to harigel/serverless-plugin-typescript that referenced this issue Mar 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.