Henning
Henning

Reputation: 166

Where is the console.log output?

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.

Upvotes: 3

Views: 6969

Answers (2)

Andre Weinand
Andre Weinand

Reputation: 1977

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.

Upvotes: 2

Fenton
Fenton

Reputation: 250922

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

Upvotes: 1

Related Questions