Visual Studio Code Opening in Browser - python-3.x

I downloaded VSC and recently for a course I opened jupyter notebook in ubuntu. Now when I try running my programs in VSC it keeps opening the browser in chrome and says "This site can't be reached: local host failed to connect". I looked at some websites and they said to delete
"action": "openExternally",
"pattern": "^\\s*Now listening on:\\s+(https?://\\S+)"
},
from the launch:json file. But when I open the launch.json file it says
{
// 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": "pwa-chrome",
"request": "launch",
"name": "Launch Chrome against localhost",
"url": "http://localhost:8080",
"webRoot": "${workspaceFolder}"
}
]
}
Could someone please help me?
Thank you for your time

Just get rid of (or comment out) this entire section.
"type": "pwa-chrome",
"request": "launch",
"name": "Launch Chrome against localhost",
"url": "http://localhost:8080",
"webRoot": "${workspaceFolder}"
This is instructions to open chrome, so if you remove it, chrome won't open on run.
Add the following settings to run python normally -
"name": "Python: Current File",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal"
For more details view the vs code page on launch.json config.

Related

How can I launch Chrome on Linux with remote debugging enabled?

I don't know where Chrome is launching from or how to change its arguments.
I want to add --remote-debugging-port=9222 to the command line arguments
I tried *, dev, various paths:
{
// 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": "chrome",
"request": "launch",
"runtimeExecutable": "/var/lib/flatpak/app/com.google.Chrome/current/active/files/bin/chrome",
"name": "Launch Chrome against localhost",
"url": "http://localhost:3000",
"webRoot": "${workspaceFolder}"
},
{
"type": "chrome",
"request": "attach",
"name": "Attach to Chrome",
"port": 9222,
"urlFilter": "http://localhost:3000/*",
"webRoot": "${workspaceFolder}"
}
]
}
I always got an error. Chrome launches ok from the app toolbar. on launch, i tcant find chrome. on attach, it cant find port. I cant figure out or find on google searhc, how to use add argument for 9222. if i could do that i htink i attach would work.
i tried to laucn chrome from terminal but nothing worksd there either. chrome or google-chrome command not found. if i launch actual executable from actual path it wont launch b/c it cant find pieces of itself, even if i launch it from the folder its already in.
so the other similar questions wont give me a solution b/c they are for windows or mac or they suggest launching a command that doesn t wor k for me

Node Debugging in WSL

I am using Windows 10 WSL in VSCode.
I have the extensions remote development, WSL, I have node installed, nvm as well.
When in work in a remote WSL and try to debug I don't have the Node option at all.
When I run the file I get:
No debugger available, can not send 'variables'
My launch.json is as follows:
// 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 Program",
"skipFiles": [
"<node_internals>/**"
],
"program": "${file}"
}
]
}```
Can someone please help me fix it by adding Node.js option so I can properly debug?
Thanks a lot in advance!
Did you found the solution eventually?
I add similar issue, I could get things working only by specifying the node binary path explicitly.
get your node binary path by issuing:
which node
then add it to your launch.json config:
{
"name": "Launch Program",
"program": "${workspaceFolder}/helloworld.js",
"request": "launch",
"skipFiles": [
"<node_internals>/**"
],
"type": "pwa-node",
"runtimeExecutable": "/home/user01/.nvm/versions/node/v14.18.0/bin/node"
},
Still there is something is wrong going on, even though I simply the setup tutorial:
https://learn.microsoft.com/en-us/windows/dev-environment/javascript/nodejs-on-wsl

only shown legacy and preview options for debugging node.js

I am currently trying to start a node.js project is VSCode, and I want to set up the debugger with a launch.json file. I understand the way to do this is to go to run -> add configuration, but when I do so, there is no option to select the "Node.js" environment specifically (there is Node.js (legacy) and Node.js (preview) as shown in the screenshot attached). I'm currently on v10.15.1 (in another project I am able to debug in a 'pure' Node.js environment, where the type property of configurations in launch.json is set as "node") - is this supposed to cause issues?
this stackoverflow post can help you.
In summary, legacy and preview means old and new nodejs debugger in vscode, respectively.
The following json snippets show the difference between launch.json files using the two debuggers, and only the type field differs.
// node-preview
"configurations": [
{
"type": "pwa-node", //differs
"request": "launch",
"name": "Launch Program",
"skipFiles": [
"<node_internals>/**"
],
"program": "${file}"
}
]
//node-legacy
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"skipFiles": [
"<node_internals>/**"
],
"program": "${file}"
}
]

Can i skip node internal modules in nodejs debugging while using visual studio code? [duplicate]

When debugging in vscode I'd like to make some "blackboxing" and do not enter into code I didn't write. How can I do this?
In your launch or attach debug task you can enter a
"skipfiles"
option which is
"An array of file or folder names, or path globs, to skip when debugging."
For example, from skipping node internals during debugging
"skipFiles": [
"${workspaceFolder}/node_modules/**/*.js",
"${workspaceFolder}/yourLibToSkip/**/*.js"
]
Also, there is a "magic reference" to the built-in core node modules you can use:
"skipFiles": [
"<node_internals>/**/*.js"
]
I was confused on where to put the setting, so just in case, if you want to skip both node_modules deps and node_internals files, your .vscode/launch.json file should look something like this:
{
"version": "0.2.0",
"configurations": [
{
"name": "Debug Tests",
"type": "node",
"request": "launch",
...
"skipFiles": ["<node_internals>/**", "${workspaceFolder}/node_modules/**/*.js"]
}
]
}
Only this worked for me.
"debug.javascript.terminalOptions": {
"skipFiles": [
"<node_internals>/**"
]
}
Just to amplify on Mauro Aguilar's correct answer, here are the complete contents of my launch.json file. Note that I am debugging a ReactJS app (circa 2021) with VS Code 1.60.2 on Windows 10 using Chrome v.94. If you're using a Linux machine or a Mac, YMMV.
{
// 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": "pwa-chrome",
"request": "launch",
"name": "Launch Chrome against localhost",
"url": "http://localhost:3000",
"webRoot": "${workspaceFolder}",
"skipFiles": ["<node_internals>/**/*.js", "${workspaceFolder}/node_modules/**/*.js"]
},
]
}
this is my launch.json file (it works for me):
{
"version": "0.2.0",
"configurations": [
{
"type": "edge",
"request": "launch",
"name": "Launch Edge against localhost",
"url": "http://localhost:4200",
"webRoot": "${workspaceFolder}",
"skipFiles": [
"${workspaceFolder}/node_modules/**/*.js"
]
}
]
}
For flutter apps, add to your user settings the following:
"dart.debugExternalLibraries": false,
"dart.debugSdkLibraries": false,
For some reason, I've needed to add both types of skip file entries,
"skipFiles": [
"${workspaceFolder}/node_modules/**/*.js",
"<node_internals>/**"
],
This seems to have resolved the issue.
"dart.debugExternalLibraries": false,
"dart.debugSdkLibraries": false,
If I add this, the debug stop after a few steps into
For Typescript built with Webpack, I had to put the exclusions in launch.json - putting them in settings.json/terminalOptions had no effect.
Also, I had to exclude the pattern of the generated files, not the source files. In my case it looks like:
"skipFiles": [
"<node_internals>/**",
"**/vendors-*",
],

VSCode Debugger pauses unexpectedly in node modules files

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

Resources