-
Notifications
You must be signed in to change notification settings - Fork 37.6k
Description
Issue Type: Bug
When trying to resolve .ts source locations and the sourcemap has relative paths e.g. "sources":["../../../src/hello.ts"] (which is the default format when you compile with tsc) then node fails to find the .ts. The error given is:
Could not load source '/src/hello.ts': Unable to retrieve source content.
It appears that node uses the HOME dir for relative paths - rather than the sourcemap directory. If you change to "./src" then you get: Could not load source '/home/ilan/src/hello.ts': Unable to retrieve source content..
Steps to repro:
git clone https://github.com/spikedata/vscode-ts-debug.git
npm i
npm run build
# ts-node = works
node -r ts-node/register src/hello.ts
# ts-node --inspect-brk = kind of works = you get the weird .js names as .ts hack
node --inspect-brk -r ts-node/register src/hello.ts
# node = doesn't work = Could not load source '/src/hello.ts': Unable to retrieve source content.
node build/main/src/hello.jsTo fix node you have to do this:
edit sourcemap
change "sources":["../../../src/hello.ts"] from relative to full path (or else a path relative to ~)
e.g. "sources":["/spike/prototype/vscode-ts-debug/src/hello.ts"]
now node build/main/src/hello.js works as expected, and thankfully so does ts-node
VS Code version: Code 1.49.0 (e790b93, 2020-09-10T13:20:50.359Z)
OS version: Linux x64 5.4.0-47-generic
System Info
| Item | Value |
|---|---|
| CPUs | Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz (8 x 2923) |
| GPU Status | 2d_canvas: enabled flash_3d: enabled flash_stage3d: enabled flash_stage3d_baseline: enabled gpu_compositing: enabled multiple_raster_threads: enabled_on oop_rasterization: disabled_off opengl: enabled_on protected_video_decode: unavailable_off rasterization: disabled_software skia_renderer: enabled_on video_decode: unavailable_off vulkan: disabled_off webgl: enabled webgl2: enabled |
| Load (avg) | 2, 1, 1 |
| Memory (System) | 15.39GB (0.56GB free) |
| Process Argv | /spike/v8/priv --no-sandbox |
| Screen Reader | no |
| VM | 0% |
| DESKTOP_SESSION | ubuntu |
| XDG_CURRENT_DESKTOP | Unity |
| XDG_SESSION_DESKTOP | ubuntu |
| XDG_SESSION_TYPE | x11 |
Extensions (27)
| Extension | Author (truncated) | Version |
|---|---|---|
| vscode-svgviewer | css | 2.0.0 |
| vue-peek | dar | 1.0.2 |
| vscode-markdownlint | Dav | 0.36.3 |
| vscode-eslint | dba | 2.1.8 |
| xml | Dot | 2.5.1 |
| gitlens | eam | 10.2.2 |
| EditorConfig | Edi | 0.15.1 |
| prettier-vscode | esb | 5.6.0 |
| vscode-statusbar-debugger | fab | 2.0.6 |
| vscode-mysql | for | 0.4.0 |
| gc-excelviewer | Gra | 3.0.40 |
| vscode-drawio | hed | 0.7.2 |
| rest-client | hum | 0.24.2 |
| json2csv | kha | 0.0.1 |
| git-graph | mhu | 1.26.0 |
| vscode-docker | ms- | 1.6.0 |
| python | ms- | 2020.8.109390 |
| vetur | oct | 0.27.3 |
| emoji | Per | 0.0.3 |
| vscode-sort-json | ric | 1.18.0 |
| LiveServer | rit | 5.6.1 |
| markdown-preview-enhanced | shd | 0.5.13 |
| stylelint | shi | 0.51.0 |
| code-spell-checker | str | 1.9.0 |
| language-stylus | sys | 1.11.0 |
| stylus-supremacy | thi | 2.14.5 |
| tom | 1.1.0 |