Skip to content

Debugging with provided launch.json file does not work if paths are specified in tsconfig.json #709

Open
@banjo

Description

@banjo

Acknowledgements

  • I read the documentation and searched existing issues to avoid duplicates
  • I understand this is a bug tracker and anything other than a proven bug will be closed
  • I understand this is a free project and relies on community contributions
  • I read and understood the Contribution guide

Minimal reproduction URL

https://github.com/banjo/tsx-error

Problem & expected behavior (under 200 words)

  1. Run the application with pnpm dev works fine.
  2. Add a breakpoint and launch with the provided launch.json, see that you get an error:
node:internal/modules/run_main:122
    triggerUncaughtException(
    ^
Waiting for the debugger to disconnect...
Error [ERR_MODULE_NOT_FOUND]: Cannot find package '@/something' imported from /Users/antonodman/code/banjo/test/tsx-error/src/index.ts
    at packageResolve (node:internal/modules/esm/resolve:838:9)
    at moduleResolve (node:internal/modules/esm/resolve:907:18)
    at defaultResolve (node:internal/modules/esm/resolve:1037:11)
    at nextResolve (node:internal/modules/esm/hooks:748:28)
    at resolveBase (file:///Users/antonodman/Library/Application%20Support/fnm/node-versions/v22.11.0/installation/lib/node_modules/tsx/dist/esm/index.mjs?1742127043794:2:3212)
    at resolveDirectory (file:///Users/antonodman/Library/Application%20Support/fnm/node-versions/v22.11.0/installation/lib/node_modules/tsx/dist/esm/index.mjs?1742127043794:2:3584)
    at resolveTsPaths (file:///Users/antonodman/Library/Application%20Support/fnm/node-versions/v22.11.0/installation/lib/node_modules/tsx/dist/esm/index.mjs?1742127043794:2:4073)
    at resolve (file:///Users/antonodman/Library/Application%20Support/fnm/node-ver
    at nextResolve (node:internal/modules/esm/hooks:748:28)
    at Hooks.resolve (node:internal/modules/esm/hooks:240:30) {
  code: 'ERR_MODULE_NOT_FOUND'
}

It seems like when I use the default launch.json file provided in the docs:

{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "tsx",
      "type": "node",
      "request": "launch",
      "program": "${file}",
      "runtimeExecutable": "tsx",
      "console": "integratedTerminal",
      "internalConsoleOptions": "neverOpen",
      "skipFiles": ["<node_internals>/**", "${workspaceFolder}/node_modules/**"]
    }
  ]
}

It does not work as it does not read the paths from tsconfig.json. However, if I add this, it works:

"runtimeArgs": ["--tsconfig", "${workspaceFolder}/tsconfig.json"],

So I guess, either that could be included in the docs, or tsx needs to be updated somehow.

Bugs are expected to be fixed by those affected by it

  • I'm interested in working on this issue

Compensating engineering work will speed up resolution and support the project

  • I'm willing to offer $10 for financial support

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions