Skip to content
the poor coder

launch json

Poor Man
Published
Reading time
2 min read
On this page

What is Launch JSON?#

Launch JSON is a configuration file used by Visual Studio Code for launching and debugging applications. It contains various settings such as the type of application to be launched, arguments to be passed, environment variables, and more.

How to create a Launch JSON file?#

To create a Launch JSON file in Visual Studio Code, follow these steps:

  1. Open your project in Visual Studio Code.
  2. Press F5 or click on the Debug icon in the sidebar.
  3. Click on the gear icon next to 'No Configurations' and select 'Add Configuration'.
  4. Select the type of application you want to launch (e.g. Node.js, Python, etc.)
  5. A default Launch JSON file will be created with some basic settings.

Understanding the Launch JSON file structure#

The default structure of a Launch JSON file looks like this:

Text

{
  "version": "0.2.0",
  "configurations": [
    {
      "type": "type",
      "request": "request",
      "name": "name",
      "program": "program",
      "args": [],
      "cwd": "cwd",
      "env": {},
      "console": "console",
      "stopOnEntry": false,
      "outFiles": []
    }
  ]
}

The important fields in this file are:

  • type: The type of application to be launched (e.g. Node.js, Python, etc.)
  • request: The type of request to be made (e.g. launch, attach, etc.)
  • name: A name for the configuration
  • program: The entry point for the application (e.g. app.js)
  • args: An array of arguments to be passed to the application
  • cwd: The current working directory for the application
  • env: An object containing environment variables to be set
  • console: The type of console to be used (internalConsole, integratedTerminal, externalTerminal)
  • stopOnEntry: Whether to stop on the first line of the application
  • outFiles: An array of output files generated by the application

Customizing the Launch JSON file#

You can customize the Launch JSON file according to your needs. For example, if you want to debug a Node.js application with nodemon, you can use the following configuration:

Text

{
  "version": "0.2.0",
  "configurations": [
    {
      "type": "node",
      "request": "launch",
      "name": "nodemon",
      "runtimeExecutable": "nodemon",
      "program": "${workspaceFolder}/index.js",
      "restart": true,
      "console": "integratedTerminal",
      "internalConsoleOptions": "neverOpen",
      "protocol": "inspector"
    }
  ]
}

In this configuration, we have used nodemon as the runtime executable, specified the entry point as index.js, enabled restart on file changes, and used the integrated terminal for the console.

You can also add multiple configurations in the Launch JSON file and switch between them as needed.

Keep going

2023

how to sort an array

How to Sort an Array If you have an array and you want to order its elements in a specific way, you need to use a sorting algorithm. There are several sorting algorithms available, but two of the most commonly used are…

javascript2 min read
2023

jquery mobile or desktop

jQuery Mobile or Desktop? As a web developer, I have had some experience with both jQuery Mobile and jQuery Desktop. Both frameworks have their pros and cons, and which one to use really depends on the specific project…

javascript1 min read
2023

node.js folder structure

Node.js Folder Structure If you are new to Node.js, it can be daunting to create a folder structure that will work for your project. The structure you choose will depend on the size and complexity of your project. Here…

javascript1 min read
ESC