-
-
Notifications
You must be signed in to change notification settings - Fork 896
How do debug nodejs language using dap mode
Ivan Yonchovski edited this page Feb 12, 2020
·
3 revisions
- Find the command that nodejs uses to run the language server:
For example, for docker-langserver
I checked the content of docker-langserver which points to /usr/lib/node_modules/dockerfile-language-server-nodejs/bin/docker-langserver
which has runs /usr/lib/node_modules/dockerfile-language-server-nodejs/lib/server.js
. So the command that runs when you do docker-langserver
is node /usr/lib/node_modules/dockerfile-language-server-nodejs/lib/server.js
.
- Alter that command to add
--inspect
flag.
(setq lsp-dockerfile-language-server-command
'("node" "--inspect=localhost:3000" "/usr/lib/node_modules/dockerfile-language-server-nodejs/lib/server.js" "--stdio" ))
Note: some of the server commands have to be set before lsp-mode
has started or you have to evaluate the lsp-clients.el
.
- Restart the language server and verify that it has started with the proper flags by doing
M-x list-processes
. - After you have configured
dap-mode
according todap-mode
readme do:
(require 'dap-node)
(dap-debug
(list :type "node"
:request "attach"
:port 3000
:program "__ignored"
:name "Debug docker language server."))
- Do
M-x dap-ui-sessions
and verify that you have attached to the language server. - Do
M-x dapui-loaded-sources
to see which are the loaded sources in which you can set breakpoints.
Screenshot: