Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Debugging tsx via NPM does not work if console is set to integratedTerminal or externalConsole, only internalConsole works #227285

Closed
Tracked by #227290
GoldenretriverYT opened this issue Aug 31, 2024 · 9 comments · Fixed by microsoft/vscode-js-debug#2082
Assignees
Labels
author-verification-requested Issues potentially verifiable by issue author bug Issue identified by VS Code Team member as probable bug debug Debug viewlet, configurations, breakpoints, adapter issues verified Verification succeeded

Comments

@GoldenretriverYT
Copy link

Does this issue occur when all extensions are disabled?: Yes/No

  • VS Code Version: 1.92.2
  • OS Version: Windows_NT x64 10.0.22631

Steps to Reproduce:

  1. Create a new folder
  2. npm init, install tsx as dev dependency. Create a npm task that runs npx tsx file.ts, and a launch.json profile that runs that task.
  3. Set the launch tasks "console" property to "integratedTerminal", the debugger will attach at first but dettach before the code is actual ever ran.
  4. If you, on the other hand, set it to "internalConsole" it works fine.

Recording 2024-08-31 at 20 07 47

Also tested in Insiders with default extensions, same issue. Also happens with ts-node in place of tsx.

@connor4312
Copy link
Member

I cannot reproduce this. Please check your terminal configuration and dotfiles (e.g. npmrc) to see if you have anything that would overwrite the NODE_OPTIONS environment variable, as this will break debugging.

@connor4312 connor4312 added the info-needed Issue requires more information from poster label Sep 6, 2024
@GoldenretriverYT
Copy link
Author

GoldenretriverYT commented Sep 6, 2024

I recently reset my computer and haven't done a lot since, so I doubt its that (and i didnt find anything suspicious). And printing NODE_OPTIONS in Node shows that they dont seem to be changed from what vscode passes:

vvvv passed by vscode
image

vvvv both variables in node
image

@connor4312
Copy link
Member

Strange can you run the Developer: Toggle Developer Tools command and check for any errors that might have been logged there?

@GoldenretriverYT
Copy link
Author

image
no errors :/

@GoldenretriverYT
Copy link
Author

Modifying the launch.json to directly use tsx or ts-node without a npm task works, so I assume it somehow breaks because of npm being inbetween?

@connor4312
Copy link
Member

connor4312 commented Sep 16, 2024

Got it. Last question, can you share the contents of C:\Program Files\nodejs\npm.cmd?

I think the command is likely running a Node process before tsx, which is being attached to in order to debug, but then by the time it launches your real program the debugger thinks it already finished.

@connor4312 connor4312 added bug Issue identified by VS Code Team member as probable bug debug Debug viewlet, configurations, breakpoints, adapter issues and removed info-needed Issue requires more information from poster labels Sep 16, 2024
@GoldenretriverYT
Copy link
Author

Sure

:: Created by npm, please don't edit manually.
@ECHO OFF

SETLOCAL

SET "NODE_EXE=%~dp0\node.exe"
IF NOT EXIST "%NODE_EXE%" (
  SET "NODE_EXE=node"
)

SET "NPM_PREFIX_JS=%~dp0\node_modules\npm\bin\npm-prefix.js"
SET "NPM_CLI_JS=%~dp0\node_modules\npm\bin\npm-cli.js"
FOR /F "delims=" %%F IN ('CALL "%NODE_EXE%" "%NPM_PREFIX_JS%"') DO (
  SET "NPM_PREFIX_NPM_CLI_JS=%%F\node_modules\npm\bin\npm-cli.js"
)
IF EXIST "%NPM_PREFIX_NPM_CLI_JS%" (
  SET "NPM_CLI_JS=%NPM_PREFIX_NPM_CLI_JS%"
)

"%NODE_EXE%" "%NPM_CLI_JS%" %*

@connor4312
Copy link
Member

FOR /F "delims=" %%F IN ('CALL "%NODE_EXE%" "%NPM_PREFIX_JS%"') DO (

that would do it

@marluanespiritusanto
Copy link

marluanespiritusanto commented Sep 18, 2024

@connor4312 I’m in the same situation, but on MacOS, after updating to Sequoia. How would it be in this case?

connor4312 added a commit to microsoft/vscode-js-debug that referenced this issue Sep 18, 2024
connor4312 added a commit to microsoft/vscode-js-debug that referenced this issue Sep 18, 2024
@connor4312 connor4312 added this to the September 2024 milestone Sep 25, 2024
@mjbvz mjbvz added verified Verification succeeded author-verification-requested Issues potentially verifiable by issue author and removed verified Verification succeeded labels Sep 26, 2024
@rzhao271 rzhao271 added the verified Verification succeeded label Sep 27, 2024
@vs-code-engineering vs-code-engineering bot locked and limited conversation to collaborators Nov 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
author-verification-requested Issues potentially verifiable by issue author bug Issue identified by VS Code Team member as probable bug debug Debug viewlet, configurations, breakpoints, adapter issues verified Verification succeeded
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants