Lambda execution failed with status 200 due to customer function error: Unexpected token import


I’am trying to deploy my new backend after splitting it up into multiple services. I also am using the react app form the online guide.
However the react app throws an “Error: Network Error”. And in my cloudwatch logs, I see the following:

Anyone knows what might be wrong?

Kind regards.

My lambda log shows this output:

This error is saying that serverless-webpack is not transpiling your Lambda functions properly.


My babelrc file looks like this:

  "plugins": ["source-map-support", "transform-runtime"],
  "presets": [
    ["env", { "node": "8.10" }],

My webpack.config.js:

const slsw = require("serverless-webpack");
const nodeExternals = require("webpack-node-externals");

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 no not want to minimize our code.
    minimize: false
  performance: {
    // Turn off size warnings for entry points
    hints: false
  // Run babel on all .js files and skip those in node_modules
  module: {
    rules: [
        test: /\.js$/,
        loader: "babel-loader",
        include: __dirname,
        exclude: /node_modules/

And my package.json has the following dependencies:

"devDependencies": {
    "aws-sdk": "^2.224.1",
    "babel-core": "^6.26.0",
    "babel-loader": "^7.1.4",
    "babel-plugin-source-map-support": "^1.0.0",
    "babel-plugin-transform-runtime": "^6.23.0",
    "babel-preset-env": "^1.6.1",
    "babel-preset-stage-3": "^6.24.1",
    "jest": "^21.2.1",
    "serverless-offline": "^3.18.0",
    "serverless-webpack": "^5.1.0",
    "webpack": "^4.2.0",
    "webpack-node-externals": "^1.6.0"
  "dependencies": {
    "babel-runtime": "^6.26.0",
    "source-map-support": "^0.4.18",
    "stripe": "^5.8.0",
    "uuid": "^3.2.1"

If I add this:

# Use serverless-webpack plugin to transpile ES6/ES7
  - serverless-webpack

To my serverless.yml, I get an error when deploying:

The webpack plugin could not find the configuration file at: /tmp/seed/source/services/notes/webpack.config.js

But thats not an valid path either, I dont have an webpack.config.js in each of my service folders, have have one at /tmp/seed/source/services

Any idea how to fix this?

Kind regards.

You need to point it to the right location:


I’ve added the following to one of my serverless.yml files for testing:

My folder structure is like this:

Shouldn’t this be fine?

Hmm I’m not really sure. You’d have to play around with it. Can you try moving it to the root level and testing to make sure it works fine?