How to run Serverless offline?

Sameer Gurung
Fuzzy Code
Published in
2 min readMar 30, 2020
Photo by Aleksandar Cvetanovic on Unsplash

In this blog, I will be demonstrating you how to run Serverless Offline using a serverless plugin that emulates AWS λ and API Gateway on your local machine to speed up your development cycles. It helps us save time as we can see logs and also debug in our local machine rather than on cloud vendors.

Local environment reduces conflict with our team members who might be dependant on using the same function (even though in development) that you are working on and might get confused to why the function is not working whilst it was working before. You can make any changes and trials carefree as you will be the only one using this environment (unless you share it to the network) 😜.

This blog is for those who already know basics of Serverless Framework and its workarounds.

The Serverless Framework helps you build serverless apps with radically less overhead and cost. It provides a powerful, unified experience to develop, deploy, test, secure and monitor your serverless applications. — Serverless Framework

Steps:

Since you already know the basics of Serverless Framework, you must have installed the framework. Next, install the package serverless-offline from npm.

  1. Install package — serverless-offline
npm install serverless-offline --save-dev

2. Add this installed plugin to your serverless project.

plugins:  - serverless-offline

3. Run serverless offline using command:

> serverless offline 

or
> sls offline

4. You can see the list of available endpoints on http://localhost:3000/ and also use http://localhost:3000/ a base endpoint. Additional usage and command line options are available on the plugin’s official documentation page.

--

--

Sameer Gurung
Fuzzy Code

A Software Engineer, who also turns to be a JavaScript enthusiast. Currently working with NodeJs, Angular, Ionic and AWS. Catch me: https://smrgrg.com