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

Not able to debug Node program using WSL #54593

Closed
isiah-lloyd opened this issue Jul 18, 2018 · 4 comments
Closed

Not able to debug Node program using WSL #54593

isiah-lloyd opened this issue Jul 18, 2018 · 4 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug debug Debug viewlet, configurations, breakpoints, adapter issues verified Verification succeeded WSL Issue when using WSL
Milestone

Comments

@isiah-lloyd
Copy link

  • VSCode Version: 1.25.1
  • OS Version: Windows 10 Home 1803

I'm trying to debug a Node application using Windows Subsytem for Linux but I don't think the paths are translating.

This is my launch.json

{
  // Use IntelliSense to learn about possible attributes.
  // Hover to view descriptions of existing attributes.
  // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
  "version": "0.2.0",
  "configurations": [
    {
      "type": "node",
      "request": "launch",
      "name": "Launch NestJS",
      "useWSL": true,
      "console": "integratedTerminal",
      "runtimeExecutable": "npm",
      "runtimeArgs": [
        "run-script",
        "start:dev"
      ],
      "port": 5000,
    }
  ]
}

and this is what appears in my console after attempting to debug:

isiah@isiah-acer:/mnt/c/Users/Isiah/Documents/Programming_Projects/etc/podcast_db/new-api$ cd "c:\Users\Isiah\Documents\Programming_Projects\etc\podcast_db\new-api" ; "C:\WINDOWS\System32\bash.exe" -ic "npm run-script start:dev"
-bash: cd: c:\Users\Isiah\Documents\Programming_Projects\etc\podcast_db\new-api: No such file or directory
C:\WINDOWS\System32\bash.exe: command not found

And for further information npm run-script start:dev runs nodemon and here is my nodemon.json:

{
  "watch": [
    "src"
  ],
  "ext": "ts",
  "ignore": [
    "src/**/*.spec.ts"
  ],
  "exec": "node -r tsconfig-paths/register --inspect=5000 --require ts-node/register src/main.ts"
}

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

@weinand weinand added debug Debug viewlet, configurations, breakpoints, adapter issues WSL Issue when using WSL labels Jul 18, 2018
@weinand weinand added the bug Issue identified by VS Code Team member as probable bug label Sep 7, 2018
@weinand weinand removed their assignment Sep 17, 2018
@weinand weinand added this to the Backlog milestone Sep 17, 2018
@weinand weinand self-assigned this Sep 17, 2018
@weinand
Copy link
Contributor

weinand commented Sep 17, 2018

This is a complex setup which is not yet supported.

@n0v1
Copy link

n0v1 commented Oct 22, 2018

I think this should work when removing "console": "integratedTerminal" from your launch configuration. "useWSL": true should be enough.

For debugging such a setup, I use the extension WSL workspaceFolder and add the following to my lauch configurations:

"localRoot": "${workspaceFolder}",
"remoteRoot": "${command:extension.vscode-wsl-workspaceFolder}",

Example that works for me:

{
  "type": "node",
  "request": "launch",
  "name": "Run NPM script in WSL",
  "useWSL": true,
  "localRoot": "${workspaceFolder}",
  "remoteRoot": "${command:extension.vscode-wsl-workspaceFolder}",
  "runtimeExecutable": "npm",
  "runtimeArgs": [
    "run-script",
    "foo",
  ],
  "internalConsoleOptions": "openOnSessionStart",
  "skipFiles": [
    "<node_internals>/**/*.js",
  ],
},

To debug mocha tests, I use this launch configuration:

{
  "type": "node",
  "request": "launch",
  "name": "Run mocha tests in WSL",
  "useWSL": true,
  "localRoot": "${workspaceFolder}",
  "remoteRoot": "${command:extension.vscode-wsl-workspaceFolder}",
  "program": "${workspaceFolder}/node_modules/mocha/bin/_mocha",
  "args": [
    "-u",
    "tdd",
    "--timeout",
    "999999",
    "--colors",
    "--exit",
    "${command:extension.vscode-wsl-workspaceFolder}/tests/test.js"
  ],
  "internalConsoleOptions": "openOnSessionStart",
  "skipFiles": [
    "<node_internals>/**/*.js",
  ],
},

Note: output will be in "Debug Console" tab.

@offero
Copy link

offero commented Jan 5, 2019

@n0v1 Worked for me. Thank you!

This is a common use case now with developing on WSL and having debugging working for me is critical for my work. Now to get python working 🤞

@Tyriar Tyriar modified the milestones: Backlog, April 2019 May 2, 2019
@Tyriar
Copy link
Member

Tyriar commented May 2, 2019

We just announced remote development with VS Code, check out the blog post for details https://code.visualstudio.com/blogs/2019/05/02/remote-development

@Tyriar Tyriar closed this as completed May 2, 2019
@miguelsolorio miguelsolorio added the verified Verification succeeded label May 7, 2019
@vscodebot vscodebot bot locked and limited conversation to collaborators Jun 16, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug debug Debug viewlet, configurations, breakpoints, adapter issues verified Verification succeeded WSL Issue when using WSL
Projects
None yet
Development

No branches or pull requests

6 participants