A collection of recipes for using VS Code with particular technologies.
microsoft / vscode-recipes Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
A collection of recipes for using VS Code with particular technologies.
Write guide on how to debug both Electron processes via composites
launch.json
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Electron: Main",
"runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron",
"runtimeArgs": [
"--remote-debugging-port=9222",
"."
],
"windows": {
"runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron.cmd"
}
},
{
"name": "Electron: Renderer",
"type": "chrome",
"request": "attach",
"port": 9222
}
],
"compounds": [
{
"name": "Electron: All",
"configurations": [
"Electron: Main",
"Electron: Renderer"
]
}
]
}
Hi, I found all the examples I can find all have one problem, the docker-compose.yml only has one service. In a real scenario, which docker-compose.yml has more than one services I don't know how to attach debugger the node service. I don't know how to set remoteRoot? Or is it possible to attach node debugger to the node service?
I still did not getting to work to debug my nextjs app with vscode. A recipe is really appreciated.
https://github.com/zeit/next.js
So I'm looking at the Launch in Docker
debug configuration at the moment and it produces this error.
web_1 | Error: Cannot find module '/server/dist/index.js'
web_1 | at Function.Module._resolveFilename (module.js:538:15)
web_1 | at Function.Module._load (module.js:468:25)
web_1 | at Function.Module.runMain (module.js:684:10)
web_1 | at startup (bootstrap_node.js:187:16)
web_1 | at bootstrap_node.js:608:3
web_1 | [nodemon] app crashed - waiting for file changes before starting...
I assume this is because the tsc-watch
task is not starting before this runs and therefore the compiled output is not available in the /dist
of the container.
Why does this project choose to have the tsc-watch
task run outside the container where as things like running the server via nodemon
inside the container?
Surely for a more portable development setup it would be better to run everything inside containers therefore making Docker the only dependency to run the project?
Would you please create a combined recipe of Angular-CLI and Docker-Typescript
Thanks in advance 🤗
https://github.com/Microsoft/vscode-recipes/blob/master/vuejs-cli/README.md
Despite following all the instructions, when I set a breakpoint and start stepping through code, I see http://localhost:8080/app.js
open in a new tab (which has tens of thousands of lines). The devtool
option is set to 'source-map'
for both dev and build. I also tried '#source-map'
just to cover my bases, but that didn't work either.
.vscode/launch.json
below:
{
"version": "0.2.0",
"configurations": [
{
"type": "chrome",
"request": "launch",
"name": "Vue: Chrome",
"url": "http://localhost:8080",
"webRoot": "${workspaceFolder}/src",
"breakOnLoad": true,
"sourceMapPathOverrides": {
"webpack:///src/*": "${webRoot}/*"
}
}
]
}
I tried to help a user debugging Emscripten translated C/C++ to JavaScript:
I compiled with:
./emcc -g4 tests/hello_world.c
The launch config for this looks like this:
{
// 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",
"protocol": "inspector",
"program": "${workspaceRoot}/a.out.js"
}
]
}
In order to set breakpoints in *.c files (without having a C/C++ extension installed), I had to enable a special VS Code option for the workspace:
The source map looks like this:
{
"version": 3,
"sources": [
"tests/hello_world.c"
],
"names": [
],
"mappings": ";;;;;;;;;;;;;AAGA;AAAA;;;;AACA;AAAA;AAAA;AADA;AAAA;AAAA;;AAGA",
"file": "a.out.js",
"sourcesContent": [
"#include <stdio.h>\n\nint main() {\n for (int i; i < 100; i++) {\n printf(\"hello, world: %d\\n\", i);\n }\n return 0;\n}\n"
]
}
As you can see the hello_world.c file is inlined in the source map.
outputCapture needs to be set to std to output console.log correctly.
After following this instruction I managed to attach the debugger.
But I cannot set the breakpoint. It is not red color in VS but gray...
And another question - I could see many different processes while attaching debugger. All of them seem valid according to the instruction as every has --inspect option... How to choose the proper one?
I've followed the instructions to set up an Angular debug scenario with a new project. I added 2 things to my app.component. Here's the file:
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
title = 'app';
ngOnInit() {
var a = 1;
console.log(a);
} // This is LINE 14
go() {
var a = 100; // This is LINE 17
console.log(a);
}
}
I'm using "@angular/cli": "~1.7.1"
and "typescript": "~2.5.3"
, if that matters.
I start with npm start
. Click to add a breakpoint to Line 17, and that line shows up in the Debug view. All good so far. I press F5, Chrome opens. I click the button that triggers go()
. I see the console log has happened (line 18), but the breakpoint is not hit.
So I click Refresh in Chrome. A new tab opens in VSCODE ( titled "app.component.ts read-only inlined content from source map"), my breakpoint has been moved to Line 14, and it gets hit. The Debug view, breakpoints list is also showing the breakpoint is one Line 14.
Help me please.
Hi, thanks for your effort, I'm excited that I finally got debugging to work with Vue.js due to your recipe!
However, when setting up the launch.json
config it didn't work at first and when I tried to launch the debugger it opened a blank tab in a new Chrome instance and VSCode debugger just hung up after waiting for 10 seconds. The fix was to add userDataDir
field to the config, as described per this issue: https://github.com/Microsoft/vscode-chrome-debug/issues/111#issuecomment-225101947 After that everything worked as expected ✨
Do you mind adding a notice in the recipe about this param? I usually have two browsers opened, one per each Chrome user/profile, therefore I suspect it might work for other users without specifying this option.
P.S. Just checked: if I have any instance of Chrome already opened, it hangs as described above, otherwise it launches successfully with one of my user profiles.
{
"type": "node",
"request": "launch",
"name": "Next: Node",
"runtimeExecutable": "node",
"runtimeArgs": [
"--inspect",
"koa"
],
"port": 9229,
"console": "integratedTerminal"
}
Cannot connect to runtime process, timeout after 10000 ms - (reason: Cannot connect to the target: connect ECONNREFUSED 127.0.0.1:9229).
Following the Vue.js debugging recipe with the current (1.20.1) VS Code it works like a charm for me (in the VueJS webpack HelloWorld project), thank you all for posting this !
One thing though, the debugger would time after time stop in some node VM thread which made the debugging process quite frustrating.
It took me a while to figure out that putting the BreakOnLoad option to false solves this and the debugging works impressively well now !
I would suggest to change this in the recipe to make the VS Code experience even smoother...
I was able to get everything working with the simple todo project. However, when I tried to update my actual web app project, I get the error:
Cannot connect to runtime process, timeout after 60000 ms - (reason: Cannot connect to the target: connect ECONNREFUSED 127.0.0.1:9229).
Nothing is running already on port 9229. I get the same error with higher timeout settings.
In the debug console, all that shows is:
Debugging with inspector protocol because a runtime executable is set. /usr/local/bin/npm run debug
Any ideas on how I can debug?
There's no option start the debug using incognito mode?
Cannot find runtime 'next' on PATH. Make sure to have 'next' installed.
when trying to start Next: Node
works fine with Next: Chrome
The recipe says to execute:
git clone [email protected]:meteor/simple-todos-react.git
This gives me:
Cloning into 'simple-todos-react'...
Warning: Permanently added the RSA host key for IP address '192.30.253.112' to the list of known hosts.
[email protected]: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
I'm not a git or github expert. Might be my problem.
From @jrieken on June 27, 2017 8:43
testing #29476
The last step which is about debugging test doesn't work for me. Breakpoints appear as empty circles not discs.
Copied from original issue: microsoft/vscode#29539
see tip here: microsoft/vscode-docs#1093
electron renderer debugging not working for me. I am on windows 10. The code works. See the "test" message in output.
get this error when debug as ELECTRON_RENDERER
Cannot connect to runtime process, timeout after 30000 ms - (reason: Cannot connect to the target: connect ECONNR
when run as ELECTRON_ALL, the code runs. Breaks in main process. But the breakpoints in the renderer are marked with donuts. "breakpoint ignored because generated code not found".
We are using Node.js 7.9.0, Chromium 58.0.3029.110, and Electron 1.7.9.
debugger for chrome is 3.5.0
what to do?
Really excited to debug Meteor in VSCode. However, the debugger is unable to recorgnise the values within Meteor.settings
.
The settings.json file is the standard way to set environment variables within Meteor (local vs staging vs production. However, if Meteor.settings is referenced anywhere in the code, the VSCode debugger throws an error:
TypeError: Cannot read property 'nameOfVariable' of undefined
Does anybody know a way around this?
I followed this exactly and I cannot get vscode to break. I can see Chrome flash very briefly like it wants to break in vs code but it never does.
https://github.com/Microsoft/vscode-recipes/tree/master/vuejs-cli
My launch file:
{
"version": "0.2.0",
"configurations": [
{
"type": "chrome",
"request": "launch",
"name": "vuejs: chrome",
"url": "http://localhost:8080",
"webRoot": "${workspaceFolder}/src",
"breakOnLoad": true,
"sourceMapPathOverrides": {
"webpack:///src/": "${webRoot}/"
}
}
]
}
Snippet of my index.js in conf
/**
* Source Maps
*/
productionSourceMap: true,
// https://webpack.js.org/configuration/devtool/#production
devtool: 'source-map',
I followed https://github.com/Microsoft/vscode-recipes/tree/master/Electron to configure debugging for Electron apps. I added a simple console.log("Hello World");
at the end of main.js. What did I do wrong?
This is my config for debugging Angular CLI
apps using ASP.NET Core
{
"type": "chrome",
"request": "launch",
"name": "Launch Chrome for dotnet build & ng build",
"url": "http://localhost:5000",
"runtimeArgs": [
"--user-data-dir",
"--remote-debugging-port=9222",
"--disable-session-crashed-bubble"
],
"sourceMaps": true,
"trace": true,
"webRoot": "${workspaceRoot}/wwwroot/",
"userDataDir": "${workspaceRoot}/.vscode/chrome"
}
Without specifying the sourceMaps
and correct webRoot
path to find them, the debugger is not able to show received items from the server.
Hello,
I've been looking for some ways to debug Vue.js Code, on Chrome or VSCode and found out this repository. I've managed to debug on VSCode, but was necessary to do a few tweaks:
Here are some info on my environment:
Used vue webpack template to create and build it.
And I doing something wrong, or the configuration might change on each case?
I'm trying to set up debugging for Next.js.
Using the following package.js:
{
"scripts": {
"dev": "next",
"build": "next build",
"start": "next start",
"debug": "next --inspect"
},
"dependencies": {
"next": "^4.2.3",
"react": "^16.2.0",
"react-dom": "^16.2.0"
}
}
The first time I tried to start debugging in VSCode it could not find next, so I tried installing it globally.
This just resulted in:
user$ cd /nextdebugtest ; /usr/local/bin/next --inspect
The module 'react' was not found. Next.js requires that you include it in 'dependencies' of your 'package.json'. To add it, run 'npm install --save react'
The module 'react-dom' was not found. Next.js requires that you include it in 'dependencies' of your 'package.json'. To add it, run 'npm install --save react-dom'
Error: Cannot find module 'react'
So I tried modifying the debug config to this:
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Next: Node",
"runtimeExecutable": "npm",
"runtimeArgs": ["run-script", "debug"],
"port": 9229,
"console": "integratedTerminal"
},
{
"type": "chrome",
"request": "launch",
"name": "Next: Chrome",
"url": "http://localhost:3000",
"webRoot": "${workspaceRoot}"
}
],
"compounds": [
{
"name": "Next: Full",
"configurations": ["Next: Node", "Next: Chrome"]
}
]
}
It starts next fine, but gets a timeout that it can't connect to port 9229.
Cannot connect to runtime process, timeout after 10000 ms - (reason: Cannot connect to the target: connect ECONNREFUSED 127.0.0.1:9229).
When trying to run just next with next --inspect
and browsing to http://localhost:9229/json/version
I'm just getting This site can’t be reached
.
Might be that Next.js has done some changes since this config was created.
Meteor will restart when a file is modified. VSCode node debugger will close, and the process will exit. Ideally the the debugger should wait for meteor to restart. I do not know of a setting in the launch.json that could solve this.
Expected output:
> testapp@ debug /Users/user/meteor/vscode-meteor-test
> meteor run --inspect
[[[[[ ~/meteor/vscode-meteor-test ]]]]]
=> Started proxy.
=> Started MongoDB.
W20171228-16:39:44.698(-5)? (STDERR) Debugger listening on ws://127.0.0.1:9229/8c29a2af-059f-4322-8d67-210ee4f80f8b
W20171228-16:39:44.724(-5)? (STDERR) For help see https://nodejs.org/en/docs/inspector
I20171228-16:39:45.070(-5)? !! Change me !! 2131
=> Started your app.
=> App running at: http://localhost:3000/
W20171228-16:39:54.710(-5)? (STDERR) Debugger listening on ws://127.0.0.1:9229/90b51542-3f8f-453c-944e-c89a1578d474
W20171228-16:39:54.715(-5)? (STDERR) For help see https://nodejs.org/en/docs/inspector
I20171228-16:39:55.161(-5)? !! Change me !! 21315
=> Meteor server restarted
Received output:
Debugging with inspector protocol because a runtime executable is set.
Verbose logs are written to:
/var/folders/0b/zk7t542s1sj_31mwpwyk3cy81gy8z8/T/vscode-node-debug2.txt
/usr/local/bin/npm run debug
> testapp@ debug /Users/ebajumpa/Code/meteor/vscode-meteor-test
> meteor run --inspect
[[[[[ ~/Code/meteor/vscode-meteor-test ]]]]]
=> Started proxy.
=> Started MongoDB.
W20171228-16:37:13.433(-5)? (STDERR) Debugger listening on ws://127.0.0.1:9229/1db82e6c-83e1-42b5-a005-fb0c34b77248
W20171228-16:37:13.531(-5)? (STDERR) For help see https://nodejs.org/en/docs/inspector
W20171228-16:37:13.532(-5)? (STDERR) Debugger attached.
I20171228-16:37:14.187(-5)? !! Change me !!
=> Started your app.
=> App running at: http://localhost:3000/
=> Server modified -- restarting...
I've put a sample meteor project on github using the example project meteor provides.
osx 10.12.6
vscode 1.91.1
meteor 1.6.0.1
To reproduce this issue, follow the steps
git clone https://github.com/SteelPhase/vscode-meteor-test vscode-meteor-test
cd vscode-meteor-test
meteor npm install
code --disable-extensions .
Meteor: Node
launch config!! Change me !!
on line 6 of server/main.js to any value=> Server modified -- restarting...
I'm trying to get remote debugging in a docker container to work. I have a strong linux background but at work I'm stuck with Windows (unfortunately). I think this error has to do something with Windows, but I'm not 100% sure:
PS C:\Users\MYUSER\projects\vscode-recipes\Docker-TypeScript> cd 'c:\Users\MYUSER\projects\vscode-recipes\Docker-TypeScript'; 'C:\Program Files\nodejs\npm.cmd' run docker-debug
In Zeile:1 Zeichen:99
+ ... pes\Docker-TypeScript'; 'C:\Program Files\nodejs\npm.cmd' run docker- ...
+ ~~~
Unerwartetes Token "run" in Ausdruck oder Anweisung.
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : UnexpectedToken
PS C:\Users\MYUSER\projects\vscode-recipes\Docker-TypeScript>
Hi all,
I have the following environment
I want to debug a angular-cli.
I followed the guide Chrome Debugging with Angular CLI
I just copied the content from launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "ng serve",
"type": "chrome",
"request": "launch",
"url": "http://localhost:4200/#",
"webRoot": "${workspaceRoot}"
},
{
"name": "ng test",
"type": "chrome",
"request": "launch",
"url": "http://localhost:9876/debug.html",
"webRoot": "${workspaceRoot}"
},
{
"name": "ng e2e",
"type": "node",
"request": "launch",
"program": "${workspaceRoot}/node_modules/protractor/bin/protractor",
"protocol": "inspector",
"args": ["${workspaceRoot}/protractor.conf.js"]
}
]
}
then I started in the terminalnpm start
.
I tried to start the debugger by choosing ng serve and pressing on the "play"-button.
This lead to this error:
Error processing "launch": Error: Can't find Chrome - install it or set the "runtimeExecutable" field in the launch config.
Ok, I have the chromium-browser installed on my machine.
From a terminal window I can start it by calling chromium-browser
So I added the entry "runtimeExecutable": "chromium-browser",
to my launch configuration:
here is the whole block:
{
"name": "ng serve",
"runtimeExecutable": "chromium-browser ",
"type": "chrome",
"request": "launch",
"url": "http://localhost:4200/#",
"webRoot": "${workspaceRoot}"
}
Using this configuration I get the error Attribute 'runtimeExecutable' does not exist ('chromium-browser ')
I also tried to give the full path to the executable. It doesn't help. Same error:
Attribute 'runtimeExecutable' does not exist ('/usr/bin/chromium-browser')
Any idea what I'm doing wrong? Or what to check next?
Thanks in advance.
We should add a recipe for ServerlessJS https://github.com/Microsoft/vscode-chrome-debug/issues/495#event-1244061243
Hi,
I am not able to debug in VS code for my project(was working before).
Throwing error: (node:24328) [DEP0062] DeprecationWarning: node --debug
and node --debug-brk
are invalid. Please use node --inspect
or node --inspect-brk
instead
VS Code details:
Version 1.19.1
Date 2017-12-19T09:41:01.414Z
Shell 1.7.9
Renderer 58.0.3029.110
Node 7.9.0
Architecture x64
Node version: v9.2.1
Thanks
Maybe it is just supposed to work this way.... Per the recipe if I am start client side meteor debugging and afterwards set breakpoints, the breakpoints are triggered as expected. However, if I update code then after that the previously set breakpoint are not triggered. I have to stop my client side debugging session and restart it to get the breakpoints to be active again.
Should it be working this way...?
I copied the launch.json from https://github.com/Microsoft/vscode-recipes/tree/master/Electron into an electron project in vscode, but when I run the "Electron: Main configuration I get:
Attribute 'runtimeExecutable' does not exist
the electron app runs otherwise. I'm using VSCode 1.21 - anyone ever encountered similar?
I'm not sure what the contributing policy is here, but I have a repo that demonstrates how to do server-side rendering with React and TypeScript so that component code can be shared between server and browser.
A simple Angular app: https://github.com/johnpapa/angular-tour-of-heroes
{
"version": "0.2.0",
"configurations": [
{
"type": "chrome",
"request": "launch",
"name": "Launch Chrome",
"sourceMaps": true,
"url": "http://localhost:4200",
"webRoot": "${workspaceRoot}",
"sourceMapPathOverrides": {
"webpack:///./*": "${webRoot}/*"
}
}
]
}
The sourceMapPathOverrides
was the important section...
Hi and thanks for your contribution!!
After having seen the @tonysneed NgAir I ran and turbocharged my Vs-code for my MAC.
The problem is that the MAC is only 50% of my live, the rest is Windows 10. I tried to follow the same steps and in windows the debug ng-serve command does not start compiling the App.
Is there a work around or am I doing something wrong(same steps as with MAC and works)??
If you have any hints will be fantastic.
Thanks
Visual Studio Code version: 1.19.3
Node version: 8.9.3
Meteor version: 1.6.1
Operating system: Windows 10
After pressing the green play button with "Meteor: Node" configuration, the Meteor app does not start. This error message later appears: Cannot connect to runtime process, timeout after 30000 ms - (reason: Cannot connect to the target: connect ECONNREFUSED 127.0.0.1:9229).
The Debug console correctly shows:
Debugging with inspector protocol because a runtime executable is set.
C:\Program Files\nodejs\npm.cmd run debug
If I manually run the app by typing meteor --inspect
and wait for the app to fully load, then press the play button, debugging appears to start working as the bottom status bar turns orange and the small debug control toolbar appears (pause, step over etc.), but they only stay for 10s, then it reverts back to the non-debugging mode and new lines appear in the terminal:
(STDERR) Debugger attached.
(STDERR) Debugger listening on ws://127.0.0.1:9229/426fde45-2b8f-4190-843a-90a6377d3a40
(STDERR) For help see https://nodejs.org/en/docs/inspector
The problem remains with other apps too, including a simple app via meteor create test
.
How can this problem be fixed?
How to use chrome debugger from nuxt.js?
I'm having an issue with hitting breakpoints (i.e. able to do meteor run --inspect
and the node inspector process runs, but it is not linking to my source code break points).
Meteor version: 1.6.0.1
Node version: v8.9.3
NPM version: 5.5.1
File Structure: standard suggested meteor project with /imports as the main folder; Package.json file is at the root of the project. Settings file is outside in a separate folder (I run it with --settings ../pathToSettings/settingsFile.json
)
My full launch.json looks like this:
{
// 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": "Meteor: Chrome",
"url": "http://localhost:3000",
"webRoot": "${workspaceRoot}"
},
{
"type": "node",
"request": "launch",
"name": "Meteor: Node",
"runtimeExecutable": "npm",
"runtimeArgs": ["run", "debug"],
"port": 9229,
"timeout": 30000
}
],
"compounds": [
{
"name": "Meteor: All",
"configurations": ["Meteor: Node", "Meteor: Chrome"]
}
]
}
Aside from the dependencies block w/ meteor packages, below is all i have in my package.json (names edited for simplicity - the settings file is definitely being read as I use it from the terminal. It is required to start the app properly.)
NOTE: I think the package.json file in Meteor is also used for Prod deployment. How would I specify the settings file path in the launch.json rather than here, so that it doesn't interfere with my Prod deployment?
"name": "appName",
"private": true,
"scripts": {
"start": "meteor run --settings ../pathtosettings/settingsfile.json",
"debug": "meteor run --inspect --settings ../pathtosettings/settingsfile.json"
},
Any ideas how to start debugging?
I'm looking how do to it for a very long time now,
it really slows us down not having the ability to debug from the code.
(I am using "e2e:debug": "ng e2e -ee --webdriver-update=false --aot=false --proxy-config proxy.conf.json" "
Thanks
If I create a project using "dotnet new angular", I can debug both the C# and Typescript code in Visual Studio 2017. But within Visual Studio Code, I can only debug the C#. When I try to place a breakpoint on any Typescript instruction, it says: "No symbols have been loaded for this document".
Please see the following Stackoverflow post for more info: https://stackoverflow.com/questions/47598215/cant-debug-typescript-in-vscode-on-app-created-with-dotnet-new-angular
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.