launch.json for debug vuejs in vcsode

Step 1: Open the project in Visual Studio Code

  • Open Visual Studio Code.
  • Use the File menu or the Open Folder button in the activity bar to open your Vue.js project.

Step 2: Install the Vue.js Debugger Extension

  • In Visual Studio Code, go to the Extensions view by clicking on the square icon on the left sidebar or using the shortcut Ctrl+Shift+X.
  • Search for "Vue.js Debugger" in the search bar.
  • Click on the "Install" button next to the "Vue.js Debugger" extension by Microsoft.

Step 3: Create a launch.json file

  • Press F5 or go to the Debug view by clicking on the bug icon on the left sidebar.
  • Click on the gear icon to open the launch.json file.
  • Select "Node.js" as the environment for debugging.

Step 4: Configure the launch.json file

  • Replace the contents of the launch.json file with the following configuration:
{
  "version": "0.2.0",
  "configurations": [
    {
      "type": "node",
      "request": "launch",
      "name": "Vue.js",
      "program": "${workspaceFolder}/node_modules/@vue/cli-service/bin/vue-cli-service.js",
      "args": ["serve"]
    }
  ]
}

Step 5: Start the debugger

  • Save the launch.json file.
  • Press F5 or click on the green arrow icon in the Debug view to start the debugger.
  • The Vue.js project will be compiled and launched in a browser window.

Step 6: Debug your Vue.js application

  • Set breakpoints in your Vue.js code by clicking on the line numbers in the editor.
  • Interact with your Vue.js application in the browser window.
  • The debugger will pause execution at the breakpoints, allowing you to inspect variables and step through your code.

That's it! You have now configured Visual Studio Code to debug Vue.js applications using the Vue.js Debugger extension. You can now use the debugger to troubleshoot and understand the behavior of your Vue.js code.