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

2

67

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"?

Yaroslavl answered 16/8, 2020 at 22:19 Comment(1)
PWA means progressive web app[s], not specific to vscode.Centuple
V
47

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. Note: See 2022 update below.

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.

Update 2022

As of July 2022, pwa-node is not preview anymore. Now it's the default debugger. There is no more Node.js(Preview) option. However, selecting Node.js produces a launch.json file that has "type": "pwa-node". The older extensions will be deprecated.

Virtue answered 8/10, 2020 at 11:32 Comment(3)
@OldGeezer, as mentioned in the answer, pwa-node is a nightly build which is also known as preview build. node is a regular, more stable build. Use pwa-node if you want the latest features like progressive web apps, but it may not be production ready yet.Virtue
2022 update: When clicking create a launch.json file under the big blue Run and Debug, the options are Node, VS Code Extension Development, Web App (Chrome), Web App (Edge), Install an extension for Javascript.... There is no more Preview option. However, selecting Node produces a launch.json file that has "type": "pwa-node". Is something amiss?Undershot
@OldGeezer, thanks for pointing it out. pwa-node is not preview anymore. Now it's the default debugger. The older extensions will be deprecated.Virtue
H
21

The pwa- prefix is/was a way to target VS Code's new JavaScript debugger, which at the time was named vscode-pwa.

https://github.com/microsoft/vscode-js-debug/pull/32

Talking with Kai and Rob, something we want to do is make the PWA extension a drop-in replacement for the existing two Chrome and Node debug extensions. Therefore we want to have the PWA extension be able to read and support the existing configuration settings, and be invoked by launching the chrome and node types. More work, coming soon in a followup PR, will be needed to actually deal with these settings.

This also moved the build to a Gulp system, supporting NLS and matching the existing extensions. Part of the build is the ability to have the types and commands be prefixed with pwa-: running gulp will generate an extension that registers types pwa-node and pwa-chrome, while gulp --drop-in will remove these prefixes. This lets us develop and debug the extension using the existing packages, until such time as we want to start dogfooding it.

Also here they talk about how to use the targeting mechanism: https://github.com/microsoft/vscode/issues/85984

Hellenhellene answered 30/8, 2020 at 22:1 Comment(4)
Does anyone know what the PWA acronym stands for? (In the context I've seen it in, it doesn't appear to mean "progressive web apps", which is common meaning of that acronym in web development.)Vituperation
@Vituperation Might really just be "Progressive Web Apps". See the linked logo (resources/pwa.png) in this commit github.com/microsoft/vscode-js-debug/commit/…. It is a logo for PWA. Some of the commits 09c9ce22e also contains codes using ServiceWorkers, CacheStore and Puppeteer. Perhaps this was originally created for debugging PWA apps. See also efa26ae84, when it is renamed from CDP (Code Debug Protocol?) to PWAValdes
Yeah, but pwa-node sounds like a nonsense.Lekishalela
Can we prepend pwa- to any type and it will point to using the new JS Debugger?Bah

© 2022 - 2024 — McMap. All rights reserved.