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.

Empty files in serverless package zip

See original GitHub issue

This is a (Bug Report / Feature Proposal)

Bug

Description

For bug reports:

  • What went wrong: All the files in the .serverless/<package>.zip are empty.
  • What did you expect should have happened: non-empty files
  • What was the config you used:

I have just tried to run sls package in one of the example project with same result, empty files in ZIP:

serverless.yml

...
  webpack:
    webpackConfig: ./webpack.config.js
    includeModules: true
...

webpack.config.js

const slsw = require("serverless-webpack")
const nodeExternals = require("webpack-node-externals")
// const CopyPlugin = require("copy-webpack-plugin")

module.exports = {
  entry: slsw.lib.entries,
  target: 'node',
  // Generate sourcemaps for proper error messages
  devtool: 'source-map',
  // Since 'aws-sdk' is not compatible with webpack,
  // we exclude all node dependencies
  externals: [nodeExternals()],
  mode: slsw.lib.webpack.isLocal ? "development" : "production",
  optimization: {
    // We do not want to minimize our code.
    minimize: false
  },
  performance: {
    // Turn off size warnings for entry points
    hints: false
  },
  // node: false,
  // devtool: 'inline-cheap-module-source-map',
  // Run babel on all .js files and skip those in node_modules
  module: {
    rules: [
      {
        test: /\.js$/,
        include: __dirname,
        exclude: /node_modules/,
        use: [
          {
            loader: 'babel-loader',
            options: {
              presets: [
                [
                  '@babel/preset-env',
                  {
                    targets: { node: '12' },
                    useBuiltIns: 'usage',
                    corejs: 3,
                  },
                ],
              ],
            },
          },
        ],
      },
    ],
  },
  plugins: [
    // TODO
    // new CopyPlugin([
      // 'path/to/specific/file',
      // 'recursive/directory/**',
    // ]),
  ],
};

Additional Data

  • Serverless-Webpack Version you’re using: “serverless-webpack”: “^5.3.5”,
  • Webpack version you’re using: “webpack”: “4.44.2”,
  • Serverless Framework Version you’re using: 1.83.2
  • Operating System: MacOS

I have tried other version combinations too: Serverless 2.20, webpack 5.17.0, copy-webpack-plugin 7.0.0

Why empty files in ZIP?? 🤯

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
janoist1commented, Feb 3, 2021

Have a look at my SO post.

0reactions
shreddingcommented, May 25, 2021

Happens for me still on a fresh installation of everything and took me a few hours to find out why AWS was complaining about my missing handler.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Empty files in uploaded zip - Serverless Forums
I am trying to deploy my Python application to AWS with Serverless framework. When I run 'sls deploy --stage dev' from my machine,...
Read more >
Serverless Webpack generates empty files in ZIP package
I'm facing with a rather annoying and frustrating anomaly with Serverless + Webpack generating empty files in the .serverless/<package>.zip ...
Read more >
Deploying Lambda functions as .zip file archives
Learn how to use the Lambda console and the Lambda API to create and configure a function defined with a .zip file archive....
Read more >
terraform-aws-modules/lambda/aws
path/to/package.zip" } resource "aws_s3_bucket" "builds" { bucket ... way to include an empty dir if it exists node_modules # Include a file ......
Read more >
Write A Serverless Function with AWS Lambda and MongoDB
Learn how to write serverless functions with AWS Lambda and MongoDB. ... In this folder create two files: index.js and package.json . For...
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