使用 Parcel 和 Edge Chromium 对 VSCode 进行正确的调试配置

问题描述

在启动 Parcel & Edge Chromium 时,标准启动配置选项似乎不起作用。

launch 模式下,浏览器会打开一个新的 Chromium 实例,该实例会丢失所有扩展设置,而 attach 模式只是拒绝加载浏览器,或导致此错误循环:

> parcel serve src/index.html

Debugger attached.
ℹ Server running at http://localhost:1234
@parcel/workers: Cannot find module '"c:/Users/jgent/AppData/Local/Programs/Microsoft'
Require stack:
- internal/preload
Error: Cannot find module '"c:/Users/name/AppData/Local/Programs/Microsoft'      
Require stack:
- internal/preload
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:815:15)   
    at Function.Module._load (internal/modules/cjs/loader.js:667:27)
    at Module.require (internal/modules/cjs/loader.js:887:19)
    at Module._preloadModules (internal/modules/cjs/loader.js:1147:12)
    at loadPreloadModules (internal/bootstrap/pre_execution.js:446:5)
    at MessagePort.<anonymous> (internal/main/worker_thread.js:122:5)
    at MessagePort.emit (events.js:314:20)
    at MessagePort.onmessage (internal/worker/io.js:80:8)
    at MessagePort.exports.emitMessage (internal/per_context/messageport.js:11:10)

这是我当前的配置:

launch.json:

{
  "version": "0.2.0","configurations": [
    {
      "command": "npm start","name": "Parcel","request": "launch","type": "node-terminal"
    },{
      "type": "edge","version": "canary","name": "Debug","url": "http://localhost:1234","webroot": "${workspaceFolder}","breakOnLoad": true,"sourceMapPathOverrides": {
        "../*": "${webroot}/*"
      }
    }
  ],"compounds": [
    {
      "name": "Parcel/Debug","configurations": ["Debug","Parcel"]
    }
  ]
}

package.json:

{
"scripts": {
    "start": "parcel serve src/index.html"
  },}

有人有可用的配置吗?

解决方法

我终于能够使用此配置使其正常工作:

launch.json

{
  "version": "0.2.0","configurations": [
    {
      "name": "Debug","type": "pwa-msedge","request": "launch","preLaunchTask": "Parcel","url": "http://localhost:1234","webRoot": "${workspaceFolder}"
    }
  ]
}

tasks.json

{
  "version": "2.0.0","tasks": [
    {
      "label": "Parcel","type": "npm","script": "start","isBackground": true,"problemMatcher": []
    }
  ]
}

我还卸载并重新安装了 VSCode,也许这也有帮助。