Debug Node AWS Lambda Function in IntelliJ with serverless offline

Hi,

I try to debug my node js lambda function with serverless offline.

after some googling i found that

node --inspect node_modules/.bin/serverless offline

should work. But when i try to run it i get:

basedir=(dirname "(echo “$0” | sed -e ‘s,\,/,g’)")
^^^^^^^
SyntaxError: missing ) after argument list
at new Script (vm.js:79:7)
at createScript (vm.js:251:10)
at Object.runInThisContext (vm.js:303:10)
at Module._compile (internal/modules/cjs/loader.js:657:28)
at Object.Module._extensions…js (internal/modules/cjs/loader.js:700:10)
at Module.load (internal/modules/cjs/loader.js:599:32)
at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
at Function.Module._load (internal/modules/cjs/loader.js:530:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:742:12)
at startup (internal/bootstrap/node.js:283:19)

Any ideas?

Assuming you want to be able to run your lambdas in serverless-offline from IntelliJ, setup a run/debug configuration as in the attached screenshot:

If you don’t have sls installed globally, set “JavaScript file:” option to location of serverless in your local node_modules.

This setup has worked for me, and with it you can set breakpoints and step through your lambda code within IntelliJ

Hi, thanks for your response.
I guess i will have to open an github issue. Only difference is i am running on windows.
I did the same thing but i still get the exception:

basedir=(dirname "(echo “$0” | sed -e ‘s,\,/,g’)")
^^^^^^^

SyntaxError: missing ) after argument list
at new Script (vm.js:79:7)
at createScript (vm.js:251:10)
at Object.runInThisContext (vm.js:303:10)
at Module._compile (internal/modules/cjs/loader.js:657:28)
at Object.Module._extensions…js (internal/modules/cjs/loader.js:700:10)
at Module.load (internal/modules/cjs/loader.js:599:32)
at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
at Function.Module._load (internal/modules/cjs/loader.js:530:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:742:12)
at startup (internal/bootstrap/node.js:283:19)
Waiting for the debugger to disconnect…

This works fine in IntelliJ on Windows: the entry javascript file needs to be something like:

node_modules\serverless\bin\serverless.js

(The file in node_modules\.bin\sls is a shell script, not a javascript file)