How can I debug Amplify JavaScript functions on VS Code on Windows 10?
This issue came up on github under How to debug amplify function using visual studio code during invocation?, but it's closed and quite old. For example, amplify invoke function
is deprecated in favor of amplify mock function
.
I've tried this launch.config
:
{
"version": "0.2.0",
"configurations": [
{
"name": "Launch Create Reort",
"type": "node",
"request": "launch",
"program": "${env:APPDATA}/npm/node_modules/@aws-amplify/cli/bin/amplify",
"args": [
"mock",
"function",
"sayhello",
"--event",
"src/event.json",
"--timeout",
"0"
],
"console": "integratedTerminal"
}
]
}
Which will log the output, but doesn't hit any breakpoints inside the function being executed:
Setup steps:
-
Install amplify cli
npm install -g @aws-amplify/cli
-
Initialize amplify. Choose JavaScript with any framework.
amplify init # Choose your default editor: Visual Studio Code # Choose the type of app that you're building: javascript # What javascript framework are you using: none
-
Add function
amplify add function SayHello # Choose the runtime that you want to use: NodeJS # Choose the function template that you want to use: Hello World