# ES6 Functions work locally, but not when deployed (serverless-webpack)

**URL:** <https://forum.serverless.com/t/es6-functions-work-locally-but-not-when-deployed-serverless-webpack/4040>\
**Category:** Serverless Framework\
**Created:** [March 17, 2018, 6:43am UTC](https://forum.serverless.com/t/es6-functions-work-locally-but-not-when-deployed-serverless-webpack/4040 "2018-03-17T06:43:13Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![zfranklyn](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/zfranklyn/32/1789_2.png) [@zfranklyn](https://forum.serverless.com/u/zfranklyn)\
**Post date:** [March 17, 2018, 6:43am UTC](https://forum.serverless.com/t/es6-functions-work-locally-but-not-when-deployed-serverless-webpack/4040/1 "2018-03-17T06:43:13Z")

</div>

I’ve set up my project according to the `serverless-webpack` docs. My functions (written in ES6) work when invoked locally, but result in the following error when I deploy them to AWS:

```
{
    "errorMessage": "Unexpected token import",
    "errorType": "SyntaxError",
    "stackTrace": [
        "SyntaxError: Unexpected token import",
        "createScript (vm.js:56:10)",
        "Object.runInThisContext (vm.js:97:10)",
        "Module._compile (module.js:542:28)",
        "Object.Module._extensions..js (module.js:579:10)",
        "Module.load (module.js:487:32)",
        "tryModuleLoad (module.js:446:12)",
        "Function.Module._load (module.js:438:3)",
        "Module.require (module.js:497:17)",
        "require (internal/module.js:20:19)"
    ]
}

```

My current understanding is that Lambda should have recompiled the ES6 code according to my webpack.config.js settings before actually executing the code, but that doesn’t appear to be the case. Does anyone have any pointers?

webpack.config.js:  
const path = require(‘path’);  
const slsw = require(‘serverless-webpack’);  
const nodeExternals = require(“webpack-node-externals”);

```
module.exports = {
  entry: slsw.lib.entries,
  target: 'node',
  mode: 'development',
  module: {
    rules: [
      {
        test: /\.js$/,
        exclude: /node_modules/,
        use: 'babel-loader'
      }
    ]
  },
  externals: [nodeExternals(), 'pg', 'sqlite3', 'tedious', 'pg-hstore'],
  output: {
    libraryTarget: 'commonjs',
    path: path.join(__dirname, '.webpack'),
    filename: '[name].js'
  }
};

```

.babelrc:  
{  
“passPerPreset”: true,  
“presets”: [  
{ “plugins”: [“transform-runtime”] },  
{  
“passPerPreset”: false,  
“presets”: [“env”, “stage-3”]  
}  
]  
}

---

<div class="post-metadata">

**Author:** ![zfranklyn](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/zfranklyn/32/1789_2.png) [@zfranklyn](https://forum.serverless.com/u/zfranklyn)\
**Post date:** [March 17, 2018, 9:31am UTC](https://forum.serverless.com/t/es6-functions-work-locally-but-not-when-deployed-serverless-webpack/4040/2 "2018-03-17T09:31:14Z")

</div>

After 10 hours, discovered the problem: my Serverless cli was not updated.

---

<div class="post-metadata">

**Author:** ![landlight](https://avatars.discourse-cdn.com/v4/letter/l/e79b87/32.png) [@landlight](https://forum.serverless.com/u/landlight)\
**Post date:** [July 9, 2018, 8:56am UTC](https://forum.serverless.com/t/es6-functions-work-locally-but-not-when-deployed-serverless-webpack/4040/3 "2018-07-09T08:56:51Z")

</div>

Can you elaborate how do you solve this? I am having the same problem? the serverless version is the latest as well.

---

<div class="post-metadata">

**Author:** ![igoralves1](https://avatars.discourse-cdn.com/v4/letter/i/bcef8e/32.png) [@igoralves1](https://forum.serverless.com/u/igoralves1)\
**Post date:** [August 15, 2018, 9:55pm UTC](https://forum.serverless.com/t/es6-functions-work-locally-but-not-when-deployed-serverless-webpack/4040/4 "2018-08-15T21:55:45Z")

</div>

I am facing a similar issue:

The complete issue is here:[https://stackoverflow.com/questions/51687740/serverless-lambda-invoking-lambda-getting-no-errors-but-a-empty-response](https://stackoverflow.com/questions/51687740/serverless-lambda-invoking-lambda-getting-no-errors-but-a-empty-response)

And this is the error I am getting:

```auto
{
    "errorMessage": "Unexpected token (",
    "errorType": "SyntaxError",
    "stackTrace": [
        "Module.load (module.js:487:32)",
        "tryModuleLoad (module.js:446:12)",
        "Function.Module._load (module.js:438:3)",
        "Module.require (module.js:497:17)",
        "require (internal/module.js:20:19)"
    ]
}

```
