【问题标题】:Source Map problem for NPM Google Cloud packages in VSCodeVSCode 中 NPM Google Cloud 包的源映射问题
【发布时间】:2020-07-11 12:45:07
【问题描述】:

我有一个大型节点 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'

请在下面找到我的 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__/**"
  ]
}
{
    "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"
            ]
        }
    ]
}

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

Publish sources and source maps to npm

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

感谢您的帮助

更新:

我已将我的 vscode 安装从 1.47 降级到 1.46.1 并且它工作正常,所以我确定 vscode 1.47 有问题

【问题讨论】:

    标签: debugging visual-studio-code source-maps


    【解决方案1】:

    这似乎是 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
    ],
    

    如果有帮助请告诉我:)

    【讨论】:

    • 是的!谢谢!
    • 如果您想使用 ts-node,您需要使用 node 作为应用程序的类型。因此,在这种情况下,问题仍然存在。还是谢谢
    猜你喜欢
    • 2021-11-23
    • 2020-11-13
    • 2017-08-26
    • 2012-04-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-07-18
    相关资源
    最近更新 更多