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

Cannot read property 'serverless' of undefined #1140

Closed
rizowski opened this issue Apr 22, 2022 · 3 comments · Fixed by #1153
Closed

Cannot read property 'serverless' of undefined #1140

rizowski opened this issue Apr 22, 2022 · 3 comments · Fixed by #1153
Labels
Milestone

Comments

@rizowski
Copy link

rizowski commented Apr 22, 2022

This is a Bug Report

Description

When packaging or deploying it fails to find serverless. I replicated the issue with latest versions of serverless-webpack. If I revert 1 version behind the latest 5.7.0 to 5.6.1 it builds fine with the dependencies I have installed.

For bug reports:

  • What went wrong?
    When running yarn sls package - or deployment doesn't matter - I receive this error.
TypeError: Cannot read property 'serverless' of undefined
    at /../../node_modules/serverless-webpack/lib/packageModules.js:102:22
  • What did you expect should have happened?
    Build my project
  • What was the config you used?
const path = require("path");
const nodeExternals = require("webpack-node-externals");
const slsw = require("serverless-webpack");
const ForkTsCheckerWebpackPlugin = require("fork-ts-checker-webpack-plugin");

const isLocal = slsw.lib.webpack.isLocal;

module.exports = {
  entry: slsw.lib.entries,
  target: "node14",
  node: {
    __dirname: true
  },
  devtool: isLocal ? "inline-source-map" : undefined,
  externalsPresets: { node: true },
  externals: [
    nodeExternals({
      modulesFromFile: true
    })
  ],
  mode: isLocal ? "development" : "production",
  resolve: {
    extensions: [".ts", ".tsx", ".js", ".json"]
  },
  module: {
    rules: [
      {
        test: /\.tsx?$/,
        loader: "ts-loader",
        exclude: /node_modules/,
        options: {
          transpileOnly: true
        }
      },
      { test: /\.graphql?$/, loader: "@graphql-tools/webpack-loader" }
    ]
  },
  plugins: [new ForkTsCheckerWebpackPlugin({ typescript: { memoryLimit: 8192 } })],
  output: {
    libraryTarget: "commonjs",
    path: path.join(__dirname, ".webpack"),
    filename: "[name].js"
  }
};
  • What stacktrace or error message from your provider did you see?
Error:
TypeError: Cannot read property 'serverless' of undefined
    at /../../my-project/node_modules/serverless-webpack/lib/packageModules.js:102:22
    at tryCatcher (/../../my-project/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/../../my-project/node_modules/bluebird/js/release/promise.js:547:31)
    at Promise._settlePromise (/../../my-project/node_modules/bluebird/js/release/promise.js:604:18)
    at Promise._settlePromise0 (/../../my-project/node_modules/bluebird/js/release/promise.js:649:10)
    at Promise._settlePromises (/../../my-project/node_modules/bluebird/js/release/promise.js:725:18)
    at _drainQueueStep (/../../my-project/node_modules/bluebird/js/release/async.js:93:12)
    at _drainQueue (/../../my-project/node_modules/bluebird/js/release/async.js:86:9)
    at Async._drainQueues (/../../my-project/node_modules/bluebird/js/release/async.js:102:5)
    at Immediate.Async.drainQueues [as _onImmediate] (/../../my-project/node_modules/bluebird/js/release/async.js:15:14)
    at processImmediate (internal/timers.js:464:21)
error Command failed with exit code 1.

Additional Data

  • Serverless-Webpack Version you're using: 5.7.0
  • Webpack version you're using: 5.72.0
  • Serverless Framework Version you're using: 3.15.2
  • Operating System: M1 Mac Monterey 12.3.1
@3alqassab
Copy link

Same here...

@j0k3r
Copy link
Member

j0k3r commented May 8, 2022

This seems to happen when a file can be found during the zip process.
I've a fix ready but maybe it'll raise an other issue on your side because of that missing file.
Once my PR is open, it'll be great in you test it to check your project before release the patch version.

@j0k3r
Copy link
Member

j0k3r commented May 9, 2022

@3alqassab @rizowski ☝️

@j0k3r j0k3r added this to the 5.7.1 milestone May 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants