mxsdev / nvim-dap-vscode-js

nvim-dap adapter for vscode-js-debug
287 stars 30 forks source link

Need help #35

Closed TroySigX closed 1 year ago

TroySigX commented 1 year ago

I have the following config:

local dap = require('dap')
require('dap-vscode-js').setup {
    node_path = 'node',
    debugger_path = os.getenv('HOME') .. '/.local/share/nvim/mason/packages/js-debug-adapter',
    adapters = { 'pwa-node' },
}
for _, language in ipairs { 'typescript', 'javascript' } do
    dap.configurations[language] = {
        {
            type = 'pwa-node',
            request = 'launch',
            name = 'Launch file',
            program = '${file}',
            cwd = '${workspaceFolder}',
        },
        {
            type = 'pwa-node',
            request = 'attach',
            name = 'Attach',
            processId = require('dap.utils').pick_process,
            cwd = '${workspaceFolder}',
        },
        {
            type = 'pwa-node',
            request = 'launch',
            name = 'Debug Jest Tests',
            -- trace = true, -- include debugger info
            runtimeExecutable = 'node',
            runtimeArgs = {
                './node_modules/jest/bin/jest.js',
                '--runInBand',
            },
            rootPath = '${workspaceFolder}',
            cwd = '${workspaceFolder}',
            console = 'integratedTerminal',
            internalConsoleOptions = 'neverOpen',
        },
    }
end

When I launch the debugger, Dap gives this error:

Could not read source map for file:///home/troysigx/.local/share/nvim/mason/packages/js-debug-adapter/out/src/targets/out/src/common/cancellation.js: ENOENT: no such file or directory, open '/home/troysigx/.local/share/nvim/mason/packages/js-debug-adapter/out/src/targets/out/src/common/cancellation.js.map'
Could not read source map for file:///home/troysigx/.local/share/nvim/mason/packages/js-debug-adapter/out/src/targets/out/src/common/events.js: ENOENT: no such file or directory, open '/home/troysigx/.local/share/nvim/mason/packages/js-debug-adapter/out/src/targets/out/src/common/events.js.map'
Could not read source map for file:///home/troysigx/.local/share/nvim/mason/packages/js-debug-adapter/out/src/targets/out/src/common/findOpenPort.js: ENOENT: no such file or directory, open '/home/troysigx/.local/share/nvim/mason/packages/js-debug-adapter/out/src/targets/out/src/common/findOpenPort.js.map'
Could not read source map for file:///home/troysigx/.local/share/nvim/mason/packages/js-debug-adapter/out/src/targets/out/src/common/findOpenPortSync.js: ENOENT: no such file or directory, open '/home/troysigx/.local/share/nvim/mason/packages/js-debug-adapter/out/src/targets/out/src/common/findOpenPortSync.js.map'
Could not read source map for file:///home/troysigx/.local/share/nvim/mason/packages/js-debug-adapter/out/src/targets/out/src/common/knownTools.js: ENOENT: no such file or directory, open '/home/troysigx/.local/share/nvim/mason/packages/js-debug-adapter/out/src/targets/out/src/common/knownTools.js.map'
Could not read source map for file:///home/troysigx/.local/share/nvim/mason/packages/js-debug-adapter/out/src/targets/out/src/common/objUtils.js: ENOENT: no such file or directory, open '/home/troysigx/.local/share/nvim/mason/packages/js-debug-adapter/out/src/targets/out/src/common/objUtils.js.map'
Could not read source map for file:///home/troysigx/.local/share/nvim/mason/packages/js-debug-adapter/out/src/targets/out/src/common/promiseUtil.js: ENOENT: no such file or directory, open '/home/troysigx/.local/share/nvim/mason/packages/js-debug-adapter/out/src/targets/out/src/common/promiseUtil.js.map'
Could not read source map for file:///home/troysigx/.local/share/nvim/mason/packages/js-debug-adapter/out/src/targets/out/src/common/random.js: ENOENT: no such file or directory, open '/home/troysigx/.local/share/nvim/mason/packages/js-debug-adapter/out/src/targets/out/src/common/random.js.map'
Could not read source map for file:///home/troysigx/.local/share/nvim/mason/packages/js-debug-adapter/out/src/targets/out/src/dap/protocolError.js: ENOENT: no such file or directory, open '/home/troysigx/.local/share/nvim/mason/packages/js-debug-adapter/out/src/targets/out/src/dap/protocolError.js.map'
Could not read source map for file:///home/troysigx/.local/share/nvim/mason/packages/js-debug-adapter/out/src/targets/out/src/targets/node/bootloader.js: ENOENT: no such file or directory, open '/home/troysigx/.local/share/nvim/mason/packages/js-debug-adapter/out/src/targets/out/src/targets/node/bootloader.js.map'
Could not read source map for file:///home/troysigx/.local/share/nvim/mason/packages/js-debug-adapter/out/src/targets/out/src/targets/node/bootloader/environment.js: ENOENT: no such file or directory, open '/home/troysigx/.local/share/nvim/mason/packages/js-debug-adapter/out/src/targets/out/src/targets/node/bootloader/environment.js.map'
Could not read source map for file:///home/troysigx/.local/share/nvim/mason/packages/js-debug-adapter/out/src/targets/out/src/targets/node/bootloader/filters.js: ENOENT: no such file or directory, open '/home/troysigx/.local/share/nvim/mason/packages/js-debug-adapter/out/src/targets/out/src/targets/node/bootloader/filters.js.map'
Could not read source map for file:///home/troysigx/.local/share/nvim/mason/packages/js-debug-adapter/out/src/targets/out/src/targets/node/bootloader/logger.js: ENOENT: no such file or directory, open '/home/troysigx/.local/share/nvim/mason/packages/js-debug-adapter/out/src/targets/out/src/targets/node/bootloader/logger.js.map'
Could not read source map for file:///home/troysigx/.local/share/nvim/mason/packages/js-debug-adapter/out/src/targets/out/src/targets/node/bundlePaths.js: ENOENT: no such file or directory, open '/home/troysigx/.local/share/nvim/mason/packages/js-debug-adapter/out/src/targets/out/src/targets/node/bundlePaths.js.map'
Could not read source map for file:///home/troysigx/.local/share/nvim/mason/packages/js-debug-adapter/out/src/targets/out/src/targets/node/createTargetId.js: ENOENT: no such file or directory, open '/home/troysigx/.local/share/nvim/mason/packages/js-debug-adapter/out/src/targets/out/src/targets/node/createTargetId.js.map'
Could not read source map for file:///home/troysigx/.local/share/nvim/mason/packages/js-debug-adapter/out/src/targets/out/src/targets/node/lease-file.js: ENOENT: no such file or directory, open '/home/troysigx/.local/share/nvim/mason/packages/js-debug-adapter/out/src/targets/out/src/targets/node/lease-file.js.map'
Uncaught TypeError TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".ts" for /mnt/HDD/umass/umass-projects/cs220/03-more-image-processing-with-hof/src/moreImageProcessing.ts
    at __node_internal_captureLargerStackTrace (internal/errors:490:5)
    at NodeError (internal/errors:399:5)
    at getFileProtocolModuleFormat (internal/modules/esm/get_format:74:9)
    at defaultGetFormat (internal/modules/esm/get_format:114:38)
    at defaultLoad (internal/modules/esm/load:81:20)
    at nextLoad (internal/modules/esm/loader:163:28)
    at load (internal/modules/esm/loader:597:26)
    at moduleProvider (internal/modules/esm/loader:449:22)
    at ModuleJob (internal/modules/esm/module_job:63:26)
    at #createModuleJob (internal/modules/esm/loader:472:17)
    at getModuleJob (internal/modules/esm/loader:426:34)
    at processTicksAndRejections (internal/process/task_queues:95:5)
    --- await ---
    at processTicksAndRejections (internal/process/task_queues:95:5)
    --- await ---
    at runMainESM (internal/modules/run_main:53:21)
    at executeUserEntryPoint (internal/modules/run_main:79:5)
    at <anonymous> (internal/main/run_main_module:23:47)

I am using vscode-js-debug 1.76.0

cw0 commented 1 year ago

I have a similar issue with it not being able to detect sourcemaps for mason packages. Not sure whats going on with that last error though. Whats the rest of your config?

TroySigX commented 1 year ago

That's all of my config for js debugger, the rest is for my other plugins

TroySigX commented 1 year ago

Is it because the filetype is typescript, not javascript, and vscode-js-debug doesn't support it?

atmosuwiryo commented 1 year ago

Workaround for me:

Go to targets directory: cd ~/.local/share/nvim/mason/packages/js-debug-adapter/out/src/targets/

create symbolic link for out directory here: ln -s ../../../out out

TroySigX commented 1 year ago

Thanks @atmosuwiryo! So is it dap or js-debug problem?

atmosuwiryo commented 1 year ago

@TroySigX I dont have much time to trace why we have a wrong path here. Sorry.

serranomorante commented 11 months ago

Is it because the filetype is typescript, not javascript, and vscode-js-debug doesn't support it?

This is a good question. On vscode, using a typescript file as the entrypoint works without issues, but it seems that nvim-dap-vscode-js doesn't support typescript (without ts-node loader) and is only compatible with javascript node projects.