# Use sequelize.js ORM library with servereless

**URL:** <https://forum.serverless.com/t/use-sequelize-js-orm-library-with-servereless/3652>\
**Category:** Serverless Framework\
**Tags:** aws\
**Created:** [February 1, 2018, 3:43am UTC](https://forum.serverless.com/t/use-sequelize-js-orm-library-with-servereless/3652 "2018-02-01T03:43:51Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![x11joe](https://avatars.discourse-cdn.com/v4/letter/x/50afbb/32.png) [@x11joe](https://forum.serverless.com/u/x11joe)\
**Post date:** [February 1, 2018, 3:43am UTC](https://forum.serverless.com/t/use-sequelize-js-orm-library-with-servereless/3652/1 "2018-02-01T03:43:51Z")

</div>

I posted a detailed version including code here ([https://stackoverflow.com/questions/48554917/getting-sequelize-js-library-to-work-on-amazon-lambda](https://stackoverflow.com/questions/48554917/getting-sequelize-js-library-to-work-on-amazon-lambda)), but the basic issue is that mysql2 won’t seem to package with serverless and work with amazon lambda for some reason? I’m not sure why.

I want to confirm if anyone else is able to get sequelize library to actually work with serverless on one of their endpoints?

This is the library I’m trying to get working ([http://docs.sequelizejs.com/](http://docs.sequelizejs.com/)), very popular ORM for nodejs.

---

<div class="post-metadata">

**Author:** ![DavidWells](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/davidwells/32/201_2.png) [@DavidWells](https://forum.serverless.com/u/DavidWells)\
**Post date:** [February 28, 2018, 1:01am UTC](https://forum.serverless.com/t/use-sequelize-js-orm-library-with-servereless/3652/2 "2018-02-28T01:01:25Z")

</div>

You might need to compile the binaries for mysql2 in the linux container of the lambda environment

If you install them on your local machine they are compiled for mac/windows etc and not the AWS lambda linux distro

This post discusses how to compile native binaries for usage in lambda [https://claudiajs.com/tutorials/pandoc-lambda.html](https://claudiajs.com/tutorials/pandoc-lambda.html)

---

<div class="post-metadata">

**Author:** ![Blipts](https://avatars.discourse-cdn.com/v4/letter/b/b2d939/32.png) [@Blipts](https://forum.serverless.com/u/Blipts)\
**Post date:** [February 28, 2018, 4:59pm UTC](https://forum.serverless.com/t/use-sequelize-js-orm-library-with-servereless/3652/3 "2018-02-28T16:59:07Z")

</div>

i see that this post was written a month ago and i’m interested if you have found answers to your questions and generally if you have any updates?

---

<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 18, 2018, 12:35pm UTC](https://forum.serverless.com/t/use-sequelize-js-orm-library-with-servereless/3652/4 "2018-03-18T12:35:56Z")

</div>

According to Joe’s SO post, the problem was resolved by forcing Serverless to include the mysql library in its bundle. I believe this issue occurs because webpack does not realize that mysql is a dependency until runtime.

I had a similar problem with Sequelize + Postgres, except my missing library was “pg”. I resolved it in the same way as Joe did. Check out his post: [https://stackoverflow.com/questions/48554917/getting-sequelize-js-library-to-work-on-amazon-lambda](https://stackoverflow.com/questions/48554917/getting-sequelize-js-library-to-work-on-amazon-lambda)

---

<div class="post-metadata">

**Author:** ![rsshilli](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/rsshilli/32/7525_2.png) [@rsshilli](https://forum.serverless.com/u/rsshilli)\
**Post date:** [November 9, 2018, 8:17pm UTC](https://forum.serverless.com/t/use-sequelize-js-orm-library-with-servereless/3652/5 "2018-11-09T20:17:08Z")

</div>

We’ve been using Serverless with Sequelize 3 for years in Lambda. It works fine. There’s a connection pool issue in Sequelize 4 that was just fixed recently to make it work for Lambda as well. I don’t know if it’s integrated yet.

We’re not using Webpack on the back end (just our front end) so maybe that’s why we never had an issue with the MySQL 2 library. We certainly didn’t have to recompile anything and most of our developers are on Windows.
