3

I cannot find the console.log output. I've tried Ctrl-shift-C to open up a shell but got

[8710:0507/113328:INFO:CONSOLE(141)] "Uncaught Error: spawn x-terminal-emulator ENOENT", source: events.js (141).

Also, the F12 console gives no console output for the app.

Jan Rüegg
  • 9,587
  • 8
  • 63
  • 105
Henning
  • 156
  • 2
  • 5
  • Do you mean the output of the app you are debuggin with VSCode? – Benjamin Pasero May 07 '15 at 13:19
  • I am just testing debugging a command line node app with some console.log statements. I've found that VSCode spawns a new subprocess /usr/bin/node --debug-brk=56058 app.js {options} and that 'lsof -p {nodeprocess}' says that stdout/1u is connected to a unix socket. I was expecting stdout on the View/Output menu in VSCode – Henning May 08 '15 at 12:10

2 Answers2

2

By default Visual Studio Code launches a program for debugging in the Debug Console where you can see the program's stderr and stdout output. In addition the Debug Console is a REPL so you can interact with the debug session and evaluate expressions (if supported by the debug extension you are using). A consequence of this REPL functionality is that if your program reads from stdin, you cannot interact with it through the Debug Console. The solution is to configure the debug session to use the Integrated Terminal or External Terminal instead of the Debug Console. For node.js debugging the former can be achieved by adding a "console": "integratedTerminal" attribute to the launch configuration.

Andre Weinand
  • 1,907
  • 11
  • 8
1

You can open the terminal (Windows or Linux) using CTRL + ` (backtick), or using "View -> Integrated Terminal", which will also show you the different key bindings if you have a different set up, for example mine appears to be CTRL + ' (single quote) despite what the documentation says.

The integrated terminal and the output window are all part of the toolbar that is displayed - so to see output switch to the "OUTPUT" tab.

Output and Terminal

The output tab contains things like task output, the terminal tab can be used to run commands and see the output, you could run node consoleapp.js and you'd see the output inline.

If you are using a task runner, such as Gulp, you can run the tasks using the VSCode task runner (appears in output) and you can visualise the tasks with extensions, like Gulp Tasks.

The Gulp Task visualisation is shown below your file list, but the output of running the tasks still appears in your "OUTPUT" tab.

Gulp Runner

Fenton
  • 241,084
  • 71
  • 387
  • 401
  • I was thinking of the output of console.log statements for a command line app. It seems impossible at the moment. I've found that its possible to redirect stdout of a running process in [link](http://stackoverflow.com/questions/1323956/how-to-redirect-output-of-an-already-running-process) – Henning May 08 '15 at 12:34
  • Showing the output of tasks is completely unrelated to showing the output of running or debugging a program (e.g. the output produced by `console.log`). So this answer does not help. – Andre Weinand Dec 06 '17 at 09:34