Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In vscode using node.js, ctrl+F5 always asks for “select environment”. This didn't happen a few weeks ago

Tags:

Whenever I press F5 or Ctrl+F5, vscode asks me to "select Environment". I have to choose Node.js every time. Somebody has given this solution: Run > Add Configuration > select Environment. It works for that particular folder. However, when I change folders the problem persists. How can I set up configurations globally? The worst part is that this problem started appearing since 4-5 weeks. Before that vscode was automatically debugging & running my files on node.js

like image 525
Aayushi Shah Avatar asked Jul 08 '20 16:07

Aayushi Shah


People also ask

Why is F5 not working in VS Code?

The reason for not showing up the Extension Development Host window by pressing F5 in the first place is because my VS code workspace is not inside the project directory. The project directory contains the setup for launching the Extension Development Host window in launch.

What does F5 do in VS Code?

F5 ⮕ Start/Continue This is the shortcut to initiate a debugging session or continue the session if paused.

What is Ctrl F5 in Visual Studio?

F5 is used to start your project in debug mode and Ctrl-F5 is used to start your project without debug mode.

How do you set a VS Code environment?

From within VS Code, you can create non-global environments, using virtual environments or Anaconda, by opening the Command Palette (Ctrl+Shift+P), start typing the Python: Create Environment command to search, and then select the command. The command presents a list of environment types: Venv or Conda.


2 Answers

I found a workaround. Installed this free extension code runner. https://marketplace.visualstudio.com/items?itemName=formulahendry.code-runner I had to set a custom shortcut key for enabling it to run since Ctrl+Alt+N didn't work for me.

like image 110
Aayushi Shah Avatar answered Sep 22 '22 03:09

Aayushi Shah


The type key is missing in /.vscode\launch.json (Access it from the top left gear icon or open it in vscode), please see @Andy's answer:

{
"version": "0.2.0",
"configurations": [
    {
        "type": "node", // to avoid the environment Select
        "request": "launch",
        "name": "Debug File",
        "program": "${file}"
    }
]

}

If the type key is not there, Vscode asks you about the type.

like image 36
Timo Avatar answered Sep 25 '22 03:09

Timo