DEV Community

Ry
Ry

Posted on • Originally published at tenmilesquare.com

3 1

How to Debug Node Serverless Using JetBrains WebStorm

One of the most useful tools in a developer's quiver is the debugger. The debugger allows a developer to not only step through code and track down bugs, but it is useful as a way to profile data structures. I find the ability to profile data structures to be extremely useful when working with scripting languages such as Python and Node.

Recently I was working on a Node serverless project and had no idea what fields existed on the serverless lambda objects (event, context, callback). When I went looking how to debug serverless, I struggled to find a solution that detailed debugging serverless in JetBrains WebStorm. The following will get you started debugging node serverless using JetBrains WebStorm.

Alt Text

There are a ton of tutorials on how to install node, serverless, WebStorm, so I've assumed you've already taken care of that. For the purpose of this tutorial, we will be using macOS Mojave. Some locations may vary depending on your OS.

  1. Create a new node configuration: In the toolbar click Run --> Edit Configurations...

Alt Text

2. Create a new node configuration by click + and then Node.js from the dropdown

  • Fill in the configuration details
    • Name: Anything you want
    • Working directory: This will default to the root of your project. Be sure it points to the directory with your serverless.js file
    • JavaScript file: this should point to the serverless binary: Typically /usr/local/bin/sls If you do not know where sls is installed you can find it by typing which sls in the terminal
    • Application parameters: 'offline'
      • Be sure to add any additional parameters you might need such as '-s local'

If you launch the Configuration as debug, the WebStorm debugger will automatically be hooked into the node process.

This debug configuration may be obvious to a seasoned node developer, but if you're a language transplant like me, you may need help getting started with debugging serverless using WebStorm. This configuration will definitely help you get started understanding the framework and squashing those pesky scripting bugs.

SurveyJS custom survey software

JavaScript UI Libraries for Surveys and Forms

SurveyJS lets you build a JSON-based form management system that integrates with any backend, giving you full control over your data and no user limits. Includes support for custom question types, skip logic, integrated CCS editor, PDF export, real-time analytics & more.

Learn more

Top comments (0)

SurveyJS custom survey software

JavaScript Form Builder UI Component

Generate dynamic JSON-driven forms directly in your JavaScript app (Angular, React, Vue.js, jQuery) with a fully customizable drag-and-drop form builder. Easily integrate with any backend system and retain full ownership over your data, with no user or form submission limits.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay