Executing a node-webkit application from vscode - json

I am testing node-webkit in vscode, but I am having issues executing it.
In my launch.json file I have this:
{
"version": "0.2.0",
"configurations": [
{
"name": "Launch",
"type": "node",
"request": "launch",
"program": "index.html",
"stopOnEntry": false,
"args": [],
"cwd": ".",
"runtimeExecutable": "/home/ryan/nwjs/nw",
"runtimeArgs": [
"--nolazy"
],
"env": {
"NODE_ENV": "development"
},
"externalConsole": false,
"sourceMaps": false,
"outDir": null
},
{
"name": "Attach",
"type": "node",
"request": "attach",
"port": 5858
}
]
}
cannot launch program '/home/ryan/Test/index.html'; enabling source maps might help
From the commandline I would run this:
/home/ryan/nwjs/nw /home/ryan/Test
And it runs the application just fine.
So, am I setting this up wrong or something?

Related

Error in debugging the vs code: could not connect to the localhost

Cannot connect to localhost .Could not debug at localhost it keeps showing this whenever i try to run the code .Please help out
json -
{
"folders": [],
"launch": {
"version": "0.2.0",
"configurations": [
{
"name": "Attach to Chrome",
"port": 9222,
"request": "attach",
"type": "chrome",
"webRoot": "${workspaceFolder}"
}
]
},
"extensions": {
"recommendations": [
"formulahendry.code-runner"
]
},
"settings": {
"code-runner.clearPreviousOutput": true,
"json.format.keepLines": true,
"json.format.enable": false,
"code-runner.runInTerminal": true
}
}
i tried to run and debug code but it showed this error

How Launch Multiple HTML files in Visual Studio Code?

I am trying to launch HTML multiple files in the same folder, and open them in Chrome (not a new window with every file) in Visual Studio Code. I tried this solution: Multiple Launch Files in Visual Studio Code, but I think, I am missing something.
I always get the message to close my current debug session before starting a new one.
Here is my launch.json file for the folder:
{
// 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": [
{
"name": "Chrome1",
"request": "launch",
"type": "pwa-chrome",
"webRoot": "${workspaceFolder}",
"file":"${file}"
},
{
"name": "Chrome2",
"request": "launch",
"type": "pwa-chrome",
"webRoot": "${workspaceFolder}",
"file": "${file}"
},
{
"name": "Chrome3",
"request": "launch",
"type": "pwa-chrome",
"webRoot": "${workspaceFolder}",
"file": "${file}"
}
],
"compounds": [
{
"name": "Chrome1/Chrome2/Chrome3",
"configurations": ["Launch Chrome","Launch Chrome","Launch Chrome"],
"preLaunchTask": "${defaultBuildTask}"
}
]
}
Thanks!
it does open chrome with 3 tab for 3 debug.
{
// 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",
"name": "Chrome1",
"file": "${workspaceFolder}/a.html"
}, {
"type": "chrome",
"request": "launch",
"name": "Chrome2",
"file": "${workspaceFolder}/b.html"
}, {
"type": "chrome",
"request": "launch",
"name": "Chrome3",
"file": "${workspaceFolder}/c.html"
}
],
"compounds": [{
"name": "Chrome123",
"configurations": ["Chrome1", "Chrome2", "Chrome3"],
}]
}

Sequential launch in VSCode debugging

Given answered and solved partially regarding this question, I have now the following launch configurations to debug my react-redux + electron app.
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Main",
"program": "${workspaceFolder}/src/main.js",
"protocol": "inspector",
"runtimeExecutable": "${workspaceFolder}/node_modules/.bin/electron",
"runtimeArgs": [
"--remote-debugging-port=9229",
"."
],
"windows": {
"runtimeExecutable": "${workspaceFolder}/node_modules/.bin/electron.cmd"
}
},
{
"type": "node",
"request": "launch",
"name": "NPM",
"runtimeExecutable": "npm",
"runtimeArgs": [
"run-script",
"start"
],
"port": 9229
},
{
"type": "chrome",
"request": "launch",
"name": "Renderer",
"url": "https://localhost:3000",
"webRoot": "${workspaceFolder}/src",
"runtimeExecutable": "C:/Users/[username]/AppData/Local/Programs/Opera developer/launcher.exe",
"runtimeArgs": [
"--remote-debugging-port=9229"
],
"port": 9229
}
],
"compounds": [
{
"name": "All",
"configurations": [
"Main",
"NPM",
"Renderer"
]
}
]
}
So it works as this: the NPM configuration starts the node.js server and then Renderer and Main respectively debugs the front-end part and back-end part.
However, when the compound setting is launched, all of them are executed at one time and both https://localhost:3000/ and election app shows blank screen until the server is completely set up.
For now, it is okay to just reload the webpage and the electron client once the server starts, but I'm just curious if there is a way to make a sequential-launch order to make it further elegant. Any good ideas?
I think you can make your renderer code a little more elegant by doing an attach instead of a launch.
For example I use a compound where I launch the main, and then attach to the renderer with the following (no reload needed).
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch",
"cwd": "${workspaceRoot}/src/app",
"runtimeExecutable": "${workspaceRoot}/src/app/node_modules/.bin/electron",
"windows": {
"runtimeExecutable": "${workspaceRoot}/src/app/node_modules/.bin/electron.cmd"
},
"runtimeArgs": [
"${workspaceRoot}/src/app",
"--remote-debugging-port=9222"
],
"console": "integratedTerminal",
"sourceMaps": true,
"outFiles": [
"${workspaceRoot}/src/app/out/**/*.js",
],
"protocol": "inspector",
},
{
"type": "chrome",
"request": "attach",
"name": "Attach to Renderer",
"trace": true,
"webRoot": "${workspaceRoot}/src/app",
"sourceMaps": true,
"port": 9222,
"timeout": 60000
},
],
"compounds": [
{
"name": "App Main & Renderer",
"configurations": [
"Launch App Main",
"Attach to App Renderer"
]
}
]
}

vs code to run c code

I have an existing code base that builds with a makefile and I'd like to use Visual Studio Code to run it.
There are my launch.json and tasks.json.
{
"version": "0.2.0",
"configurations": [{
"name": "C Launch (GDB)",
"type": "cppdbg",
"request": "launch",
"launchOptionType": "Local",
"targetArchitecture": "x64",
"cwd": "${workspaceRoot}",
"program": "E:/code/c",
"miDebuggerPath": "E:/Program Files/TDM-GCC-64/bin/gdb64.exe",
"args": [""],
"stopAtEntry": false,
"externalConsole": true,
"preLaunchTask": "gcc"  
}]
}
{
"version": "0.1.0",
"command": "gcc",
"args": ["${file}", "-o", "${fileBasenameNoExtension}.exe", "-g3", "-Og", "-Wall", "-static-libgcc", "-std=c11", "-fexec-charset=GBK", "-finput-charset=UTF-8"],
"showOutput": "always",
"problemMatcher": {
"owner": "c",
"fileLocation": ["relative", "${workspaceRoot}"],
"pattern": {
"regexp": "^(.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$",
"file": 1,
"line": 2,
"column": 3,
"severity": 4,
"message": 5
}
}
}
then when I run Hello world,then will have some problems.
Try changing your paths to use \ instead of / on Windows. Since you have to escape \ in json strings, the actual value would be:
"program": "E:\\code\\c\\${fileBasenameNoExtension}.exe"
provided the built executable is actually at E:\code\c

Running the contributed command:'extension.node-debug.startSession' failed

After updating VSCode, I met this issue when I try to debug on macOS:
Running the contributed command:'extension.node-debug.startSession'
failed.
My launch.json is
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"program": "${file}",
"outFiles": [
"${workspaceRoot}/out/**/*.js"
]
}
]
}
Following this solution, adding "protocol": "legacy"
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"program": "${file}",
"outFiles": [
"${workspaceRoot}/out/**/*.js"
],
"protocol": "legacy"
}
]
}
The error becomes:
Cannot launch program '/app.ts';
setting the 'outFiles' attribute might help.
However, I already have outFiles.
Any other solutions? Thanks