VSCode 中 NPM Google Cloud 包的源映射问题

hat*_*ici 3 debugging source-maps visual-studio-code

我有一个大型 Node.js 应用程序。它管理 HTTP REST 请求。它是用打字稿写的。我能够毫无问题地编译和运行该应用程序。在 VSCode 中,我有一个预启动任务,它基本上编译代码。

当我想调试应用程序或尝试使用 vscode 在其中添加断点时,它会给出类似的错误消息,如下所示:

Could not read source map for file:///Users/user/Developer/yoauto/engine/node_modules/@google-cloud/paginator/build/src/resource-stream.js: ENOENT: no such file or directory, open '/Users/user/Developer/yoauto/engine/node_modules/@google-cloud/paginator/build/src/resource-stream.js.map'
Run Code Online (Sandbox Code Playgroud)

请在下面找到我的 tsconfig.json 和 launch.json:

{
  "compilerOptions": {
    "outDir": "dist/",
    "allowSyntheticDefaultImports": true,
    "esModuleInterop": true,
    "strictBindCallApply": true,
    "allowJs": false,
    "checkJs": false,
    "declaration": false,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "forceConsistentCasingInFileNames": true,
    "importHelpers": true,
    "noEmitHelpers": true,
    "lib": ["dom", "es2016", "es2017.object"],
    "target": "es6",
    "module": "commonjs",
    "noUnusedLocals": false,
    "noUnusedParameters": false,
    "noEmitOnError": true,
    "noFallthroughCasesInSwitch": true,
    "noImplicitAny": false,
    "noImplicitReturns": false,
    "noImplicitThis": false,
    "strictNullChecks": false,
    "pretty": true,
    "removeComments": false,
    "sourceMap": true,
    "moduleResolution": "node",
    "baseUrl": "src",
    "paths": {
      "@/*": ["./*"],
      "@services/*": ["./core/services/*"],
      "@domains/*": ["./core/domains/*"],
      "@providers/*": ["./core/providers/*"],
      "@controllers/*": ["./core/application/controllers/*"]
    },
    "resolveJsonModule": true
  },
  "include": ["./setup.ts", "./src/*", "./src/config/*.json", "setup.ts", "./_deploy/*.yaml"],
  "exclude": [
    "dist",
    "node_modules",
    "**/**/**.spec.ts",
    "**/**/**.e2e.ts",
    "**/**/**.spec.ts",
    "**/__tests__/**"
  ]
}
Run Code Online (Sandbox Code Playgroud)
{
    "version": "0.2.0",
    "configurations": [

        {
            "type": "node",
            "request": "launch",
            "name": "Launch Program",
            "skipFiles": [
                "<node_internals>/**"
            ],
            "program": "${workspaceFolder}/dist/setup.js",
            // "preLaunchTask": "tsc: build - tsconfig.json",
            "outFiles": [
                "${workspaceFolder}/dist/**/*.js"
            ]
        }
    ]
}
Run Code Online (Sandbox Code Playgroud)

昨天还在工作。我不知道问题所在。我在 github 上找到了最接近的问题,但不确定它是否相关。

将源代码和源映射发布到 npm

我认为问题出在 VSCode 本身,因为我能够使用最新的 webstorm 调试应用程序,没有任何问题(可能是错误的)

感谢您的帮助

更新 :

我已将我的 vscode 安装从 1.47 降级到 1.46.1 并且它有效,所以我确信 vscode 1.47 有问题

538*_*MEO 5

这似乎是 vsCode 中的一个问题,如此处发现的https://github.com/microsoft/vscode/issues/102042

要解决这个问题,请将这些行添加到您的launch.json配置中:

"type": "pwa-node",
"resolveSourceMapLocations": [
    "${workspaceFolder}/**",
    "!**/node_modules/**" // this lines prevent reading source maps from node_modules
],
Run Code Online (Sandbox Code Playgroud)

告诉我是否有帮助:)