Invoke local: Unexpected token import

Hi,

Been looking to use the serverless framework more and running into a problem invoking a function locally.
Using this import { Sequelize } from 'sequelize'; but when running locally I get the error Unexpected token import.
If I use const Sequelize = require('sequelize'); there are no issues but would ideally like to use the import if I can.

Is there something else or another plugin I need to include to allow this to work?
From what I can tell, AWS Lambdas allow for this?

Thanks,
Gary

The import syntax is not supported in the version of NodeJs supported by Lambda. I think it might be in the latest version of NodeJs (v8), but only v6.10 is supported in Lambda.

You can run a pre-compile step (e.g. using Babel) to support these newer language features, something like serverless-babel-plugin.

1 Like