Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the pwa-node type launch configuration on VSCode?

I noticed that the default launch configuration generated by VSCode for npm debugging (Launch via NPM) sets the configuration type as "pwa-node" by default.

Adding "Launch via NPM" configuration:

Adding Launch via NPM configuration

Generated configuration type:

generated type

I've searched a bit but didn't find the meaning of this (maybe something related to Progressive Web Apps?).

Does anyone know the meaning of "pwa-node" and why "pwa-node" and not "node"?

like image 898
Wayrex Avatar asked Aug 16 '20 22:08

Wayrex


People also ask

What is launch configuration in VS Code?

This vscode extension allows you to create settings to launch any number of your launch. json configurations or compound configurations via separate keybindings. These launch configs can be in any root folder in a multi-root workspace.

Does VS Code use node?

Visual Studio Code has support for the JavaScript and TypeScript languages out-of-the-box as well as Node. js debugging. However, to run a Node. js application, you will need to install the Node.

Where is launch json in VS Code?

The launch. json file is located in a . vscode folder in your workspace (project root folder).


1 Answers

The type attribute

The type attribute specifies the type of debugger to use for this launch configuration. Every installed debug extension introduces a type: node for the built-in Node debugger, for example, or php and go for the PHP and Go extensions.


type : pwa-node

Javascript Debugger is a built-in extension for debugging in VS code. This extension is installed and enabled by default in the latest versions of VS code. The "type": "pwa-node" comes from the Javascript Debugger (Nightly), the preview version. The pwa- prefix is used to distinguish which debugger should be used.

The "type": "pwa-node" is added to your launch.json when you click Node.js(Preview) instead of Node.js in the drop down menu while creating the launch.json file from the debugging section of the sidebar.

If you open the defaultSettings.json of your VS code, you can see the settings(enabled) for the preview version, they look like following:

"debug.javascript.usePreview": true, "debug.javascript.usePreviewAutoAttach": true, 

If you want to use this nightly version of the debugger extension, you need to disable the built-in debugger and install the nightly version from the marketplace. To do so, follow these steps:

  1. Open the extensions view and search for @builtin @id:ms-vscode.js-debug
  2. Right click and disable the extension.
  3. Now search for the nightly extension by typing: @id:ms-vscode.js-debug-nightly
  4. Click install and restart the VS code.

Now you can debug the Typescript and Javascript code using the JavaScript Debugger (Nightly).

If you get the error that debug type 'pwa-node' is not supported, remove the following settings from your settings.json:

"debug.node.useV3": true, "debug.chrome.useV3": true 

type : node

If you want the previous behaviour, that is "type": "node", click Node.js instead of Node.js(Preview) in the drop down menu while creating the launch.json file from the debugging section of the sidebar. You can also just type "type": "node" by hand in the launch.json instead of doing it from the menu, it won't make any difference.

If you have made the above changes for the nightly version of the Javascript Debugger, you should undo them for the built-in Javascript Debugger to work properly.

like image 171
Yogesh Umesh Vaity Avatar answered Oct 04 '22 19:10

Yogesh Umesh Vaity