I get error:
Cannot connect to runtime process, timeout after 10000ms - (reason: cannot connect to the target)
NodeJs v4.3.1 run on WSL.
The below is my launch.json
"type": "node",
"request": "attach",
"name": "Attach to WSL",
"port": 3000,
"address": "localhost",
"restart": true,
"protocol": "inspector",
"localRoot": "${workspaceFolder}/web-frontend",
"remoteRoot": "/mnt/c/workspace/.../web-frontend"
WSL uses the path from Windows so localRoot and remoteRoot are the same.
What am I missing so far?
I created a VS Code extension: WSL workspaceFolder, which will help you to automatically set the remoteRoot in your launch.json to the correct WSL path. For example my launch.json, based upon your file paths would look like below;
/vscode/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": "attach",
"name": "Attach to Remote",
"address": "localhost",
"port": 5858,
"localRoot": "${workspaceFolder}/web-frontend",
"remoteRoot": "${command:extension.vscode-wsl-workspaceFolder}/web-frontend"
}
]
}
Then to start a debug session, in the WSL terminal enter NODE_ENV=debug node --nolazy --inspect-brk=5858 before the path to the script you wish to debug.
However, you may run into problems using Node v4 because it does not support the 'inspector protocol'. I would strongly recommend you upgrade to a more recent version of Node. Currently v8 is the latest LTS version: Node.js releases
Related
I'm using VSCode to debug a node.js script running on a remote linux server on my LAN. I'm using the RemoteSSH plugging to access the scripts, save, and edit it. I can also run it from the VSCode just fine. But I tried to use this article here to setup remote debugging:
https://dakshika.medium.com/remote-debug-node-js-application-using-visual-studio-code-dc0fa0b4dec4
I did modify the commandline command to start the node.js debugger since my server has an older version of Node (Node 8.10.0). I have to use the following:
node --inspect-brk=127.0.0.1:9229 scripts/myScript.js
After running the command, it shows that node is listening for connections. But when I run my Attach launch configuration:
"version": "0.2.0",
"configurations": [
{
"name": "Attach",
"type": "node",
"request": "attach",
"port": 9229,
"address": "127.0.0.1",
"restart": false,
"sourceMaps": false,
"continueOnAttach": true,
"localRoot": "${workspaceRoot}",
"remoteRoot": null
}
]
it doesn't do anything. The run/pause/stop buttons come up but it doesn't jump to the first line of code so I can step through. Any idea what could be going on?
I was working in the azure core tools version 2 and recently updated to version 3. Now I am not able to run any functions as it is showing error message "connect Econnrefused 127.0.0.1:9091".
Here is my launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "Attach to Python Functions",
"type": "python",
"request": "attach",
"port": 9091,
"preLaunchTask": "func: host start"
}
]
}
I am working on windows machine and using 1.6.1 azure functions versions.
Do I have to change something? I checked and this is common error and reinstalling the extensions should work?I tried all those. Do you think, I am missing anything ?
Please check if the below workarounds help to:
Approach 1:
Use Integrated terminal in the VS Code and then run the Azure Functions Python:
I will also get this issue most of the time and My working launch.json configuration will be like this:
{
"version": "0.2.0",
"configurations": [
{
"name": "Python: Current file",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal"
},
{
"name": "Azure Functions",
"type": "python",
"request": "attach",
"port": 9091,
"preLaunchTask": "func: host start"
}
]
}
Approach 2:
If the above approach gets the issue still, then try changing the port number and then run the Azure Functions Python.
Approach 3:
Instead of running the Azure Functions Python from the VS Code built-in Run Menu, try with the commands func host start in the integrated terminal like:
If that does not help you, please refer to this workaround given here which solves the specific error of Azure Function Python - Error Connection Refused.
Since I upgraded my node-lambda project from 6.10 node version to 8.10 my debug failed.
My config is:
{
// informations: https://go.microsoft.com/fwlink/?linkid=830387
// usefull environnement variables list at https://code.visualstudio.com/docs/editor/variables-reference
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Debug Node Lambda ",
"program": "/usr/local/bin/node-lambda",
"args": [
"run"
],
"preLaunchTask": "debug",
"postDebugTask": "clean",
"runtimeVersion": "8.10.0",
// "protocol": "inspector"
},
}
this is my output error message:
/home/gwendal/.nvm/versions/node/v8.10.0/bin/node --inspect-brk=24258 ../../../../usr/local/bin/node-lambda run
Debugger listening on ws://127.0.0.1:24258/d27c6111-ae5e-482a-a27a-e88829fd409f
Debugger attached.
Runtime [nodejs8.10] is not supported.
main.js:53
I don't find a way to make it works...
The problem is that I didn't update my node-lambda as sudo and with -g so the 11.7 version (needed for node 8.10) didn't work. All is right now.
While running my nodejs server code through the VSCode Debugger it pauses weirdly in multiple node module library files. Then I just have to hit play button like a hundred times to finally run the whole code. This is so annoying. I have no idea how to fix it. I even tried skipping node module files and folder in launch.json file but it just doesn't seem to work. Below is my launch.json file.
{
// Use IntelliSense to learn about possible Node.js debug 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 Program",
"program": "${file}",
"cwd": "${workspaceRoot}",
"skipFiles": [
"${workspaceRoot}/node_modules/**/*.js",
"<node_internals>/**/*.js"
]
},
{
"type": "node",
"request": "attach",
"name": "Attach to Process",
"address": "localhost",
"port": 5858
}
]
}
uncheck them and it will work smoothly
I see the above when trying to debug Node.js script with Visual Studio Code.
My launch.json looks like
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "attach",
"name": "Attach to Process",
"protocol": "legacy",
"processId": "${command:PickProcess}"
}
]
}
No matter I put the line "protocol": "legacy", or not I get exactly the same error as above.
My environment
System: OSX
Node: v8.6.0
VSC: 1.17.2
Also, I run the node script with PM2.
Any suggestion would be hugely appreciated
Node v8.6 does not support "legacy" protocol. You should use the "inspector" protocol.
I ran above the same issue using the "legacy" protocol while running the Hello World Extension. After searching a bit, I stumbled on this issue, and change my launch.json file to the following as suggested by #weinand:
{
"name": "Launch Extension",
"type": "extensionHost",
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": [ "--extensionDevelopmentPath=${workspaceRoot}" ],
"outFiles": [ "${workspaceRoot}/out/src/**/*.js" ]
}
using node 8.9.1
used the latest version of the yeoman generator for the code.