question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ServerlessError: No file matches include / exclude patterns for Lambda Layer

See original GitHub issue

Getting the error ServerlessError: No file matches include / exclude patterns when trying to deploy a lambda layer.

First I package everything and run: webpack && export SLS_DEBUG=* && npx serverless package --stage dev --package ./_artifacts/serverless

My webpack.config.js is:

// dependencies
const path = require('path');

// distribution directory
const dist = 'dist/nodejs/node_modules/my-lambda-layer';

module.exports = {
  entry: './src/index.js',
  mode: 'production',
  externals: 'aws-sdk', // aws-sdk is already in Lambda environment, so don't bundle it
  output: {
    filename: 'index.js',
    path: path.resolve(__dirname, dist),
    libraryTarget: 'commonjs2'
  },
  optimization: {
    minimize: false,
  },
  target: 'node'
};
serverless.yml
service: my-lambda-layer
frameworkVersion: ^2.13.0

provider:
  name: aws
  region: us-east-2

package:
  artifact: ${opt:artifact, ''}
  
layers:
  my-lambda-layer:
    path: dist
    description: xxx
    compatibleRuntimes:
      - nodejs12.x
    retain: true
⚠️⚠️ REPLACE WITH FULL COMMAND NAME output
export SLS_DEBUG=* && npx serverless deploy --stage dev --artifact ./_artifacts/serverless/my-lambda-layer.zip

Serverless: Load command interactiveCli
Serverless: Load command config
Serverless: Load command config:credentials
Serverless: Load command config:tabcompletion
Serverless: Load command config:tabcompletion:install
Serverless: Load command config:tabcompletion:uninstall
Serverless: Load command create
Serverless: Load command install
Serverless: Load command package
Serverless: Load command deploy
Serverless: Load command deploy:function
Serverless: Load command deploy:list
Serverless: Load command deploy:list:functions
Serverless: Load command invoke
Serverless: Load command invoke:local
Serverless: Load command info
Serverless: Load command logs
Serverless: Load command metrics
Serverless: Load command print
Serverless: Load command remove
Serverless: Load command rollback
Serverless: Load command rollback:function
Serverless: Load command slstats
Serverless: Load command plugin
Serverless: Load command plugin
Serverless: Load command plugin:install
Serverless: Load command plugin
Serverless: Load command plugin:uninstall
Serverless: Load command plugin
Serverless: Load command plugin:list
Serverless: Load command plugin
Serverless: Load command plugin:search
Serverless: Load command config
Serverless: Load command config:credentials
Serverless: Load command rollback
Serverless: Load command rollback:function
Serverless: Load command upgrade
Serverless: Load command uninstall
Serverless: Load command login
Serverless: Load command logout
Serverless: Load command generate-event
Serverless: Load command test
Serverless: Load command dashboard
Serverless: Load command output
Serverless: Load command output:get
Serverless: Load command output:list
Serverless: Load command param
Serverless: Load command param:get
Serverless: Load command param:list
Serverless: Load command studio
Serverless: Invoke deploy
Serverless: Invoke package
Serverless: Invoke aws:common:validate
Serverless: Invoke aws:common:cleanupTempDir
Serverless: Packaging service...
Serverless: Excluding development dependencies...
 
  Serverless Error ---------------------------------------
 
  ServerlessError: No file matches include / exclude patterns
      at /home/jenkins/agent/workspace/my-lambda-layer_feature_jenkins/node_modules/serverless/lib/plugins/package/lib/packageService.js:274:13
      at processTicksAndRejections (internal/process/task_queues.js:97:5)
  From previous event:
      at Package.packageService (/home/jenkins/agent/workspace/my-lambda-layer_feature_jenkins/node_modules/serverless/lib/plugins/package/lib/packageService.js:94:22)
  From previous event:
      at Object.package:createDeploymentArtifacts [as hook] (/home/jenkins/agent/workspace/my-lambda-layer_feature_jenkins/node_modules/serverless/lib/plugins/package/package.js:58:71)
  From previous event:
      at PluginManager.invoke (/home/jenkins/agent/workspace/my-lambda-layer_feature_jenkins/node_modules/serverless/lib/classes/PluginManager.js:521:22)
      at /home/jenkins/agent/workspace/my-lambda-layer_feature_jenkins/node_modules/serverless/lib/classes/PluginManager.js:556:24
  From previous event:
      at PluginManager.run (/home/jenkins/agent/workspace/my-lambda-layer_feature_jenkins/node_modules/serverless/lib/classes/PluginManager.js:556:8)
      at /home/jenkins/agent/workspace/my-lambda-layer_feature_jenkins/node_modules/serverless/lib/Serverless.js:203:33
      at processImmediate (internal/timers.js:456:21)
      at process.topLevelDomainCallback (domain.js:137:15)
  From previous event:
      at Serverless.run (/home/jenkins/agent/workspace/my-lambda-layer_feature_jenkins/node_modules/serverless/lib/Serverless.js:190:74)
      at /home/jenkins/agent/workspace/my-lambda-layer_feature_jenkins/node_modules/serverless/scripts/serverless.js:50:26
 
  Get Support --------------------------------------------
     Docs:          docs.serverless.com
     Bugs:          github.com/serverless/serverless/issues
     Issues:        forum.serverless.com
 
  Your Environment Information ---------------------------
     Operating System:          linux
     Node Version:              14.2.0
     Framework Version:         2.13.0 (local)
     Plugin Version:            4.1.2
     SDK Version:               2.3.2
     Components Version:        3.4.2

Installed version

Framework Core: 2.13.0 (local)
Plugin: 4.1.2
SDK: 2.3.2
Components: 3.4.2

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
medikoocommented, Dec 4, 2020

is what I reported not a bug?

serverless.yml as put in description doesn’t reproduce reported issue.

I’ve recreated it here: https://github.com/medikoo/test-serverless/tree/issue-8576 and it deploys without issues

0reactions
corydorning53commented, Dec 4, 2020

@medikoo great thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Serverless error - No file matches include / exclude patterns
serverless is checking those files against the patterns specified in the root package:exclude and because./** matches every file and the include ...
Read more >
Serverless: No file matches include / exclude patterns #9873
In the layer, I am giving the path of the folder that is available on the root of the folder where serverless.yml is...
Read more >
Serverless-python-layers: No file matches include / exclude ...
I am trying some skeleton deployment using python. Here is my serverless.yaml. My folder structure is serverless-test |_lambdas ...
Read more >
Serverless - Include/Exclude
Serverless - Include/Exclude, We've already seen in the 'Deploying a function' chapter that to deploy functions from an existing project to AWS lambda, ......
Read more >
Serverless Deploy pipe file not found include / exclude
The issue is with deployment for lambda layers. I will update a solution when I find one.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found