Open vaibhav135 opened 1 year ago
Here's how I made it work, although I should note I didn't use this extension.
local dap = require('dap')
dap.adapters["pwa-node"] = {
type = "server",
host = "localhost",
port = "${port}", --let both ports be the same for now...
executable = {
command = "node",
-- -- 💀 Make sure to update this path to point to your installation
args = { vim.fn.stdpath('data') .. "/mason/packages/js-debug-adapter/js-debug/src/dapDebugServer.js", "${port}" },
-- command = "js-debug-adapter",
-- args = { "${port}" },
},
}
for _, language in ipairs({ "typescript", "javascript" }) do
dap.configurations[language] = {
{
type = 'pwa-node',
request = 'launch',
name = 'Launch Current File (pwa-node)',
cwd = "${workspaceFolder}", -- vim.fn.getcwd(),
args = { '${file}' },
sourceMaps = true,
protocol = 'inspector',
},
{
type = 'pwa-node',
request = 'launch',
name = 'Launch Current File (Typescript)',
cwd = "${workspaceFolder}",
runtimeArgs = { '--loader=ts-node/esm' },
program = "${file}",
runtimeExecutable = 'node',
-- args = { '${file}' },
sourceMaps = true,
protocol = 'inspector',
outFiles = { "${workspaceFolder}/**/**/*", "!**/node_modules/**" },
skipFiles = { '<node_internals>/**', 'node_modules/**' },
resolveSourceMapLocations = {
"${workspaceFolder}/**",
"!**/node_modules/**",
},
},
}
end
{ type = 'pwa-node', request = 'launch', name = 'Launch Current File (Typescript)', cwd = "${workspaceFolder}", runtimeArgs = { '--loader=ts-node/esm' }, program = "${file}", runtimeExecutable = 'node', -- args = { '${file}' }, sourceMaps = true, protocol = 'inspector', outFiles = { "${workspaceFolder}/**/**/*", "!**/node_modules/**" }, skipFiles = { '<node_internals>/**', 'node_modules/**' }, resolveSourceMapLocations = { "${workspaceFolder}/**", "!**/node_modules/**", }, }
When I try this config, I get this error when I launch the debugger, even though ts-node is installed (via Homebrew on MacOS). It works if I install ts-node as a project dependency. Do you know if there is a way to configure the debugger to use the global ts-node?
Process exited with code 1
(node:43621) ExperimentalWarning: Custom ESM Loaders is an experimental feature and might change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
Uncaught Error Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'ts-node' imported from /Users/danseravalli/Developer/personal/leetcode/3-longest-substring-without-repeating-characters/
at __node_internal_captureLargerStackTrace (internal/errors:496:5)
at NodeError (internal/errors:405:5)
at packageResolve (internal/modules/esm/resolve:890:9)
at moduleResolve (internal/modules/esm/resolve:939:20)
at defaultResolve (internal/modules/esm/resolve:1132:11)
at nextResolve (internal/modules/esm/loader:163:28)
at resolve (internal/modules/esm/loader:835:30)
at getModuleJob (internal/modules/esm/loader:424:18)
at import (internal/modules/esm/loader:524:22)
at loadModulesInIsolation (internal/process/esm_loader:92:34)
at initializeLoader (internal/process/esm_loader:61:25)
at loadESM (internal/process/esm_loader:101:11)
at runMainESM (internal/modules/run_main:60:21)
at executeUserEntryPoint (internal/modules/run_main:83:5)
at <anonymous> (internal/main/run_main_module:23:47)
--- await ---
at runMainESM (internal/modules/run_main:60:21)
at executeUserEntryPoint (internal/modules/run_main:83:5)
at <anonymous> (internal/main/run_main_module:23:47)
For this config you need to install the ts-node package with npm/yarn/etc.
Try sudo npm i -g ts-node
I am trying to debug my typescript file. And using lunar-vim btw. and getting the following error:
Error
[dap-js] Error trying to launch js-debugger: EONENT: No such file or directory.
My dap configuration