hatirlatici
hatirlatici

Reputation: 1675

Source Map problem for NPM Google Cloud packages in VSCode

I have a large node js application. It manages HTTP REST requests. It was written in typescript. I am able to compile and run the application without any problem. In VSCode, I have a pre-launch task which basically compiles the code.

When I want to debug the application or try to add breakpoints in it with vscode, it gives me similar error messages like below:

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'

Please find my tsconfig.json and launch.json below:

{
  "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"
            ]
        }
    ]
}

It was working yesterday. I do not know the problem. I found the closest issue on github but not sure it's relevant though.

Publish sources and source maps to npm

I think the problem is VSCode itself since I am able to debug the application with the latest webstorm without any problem (might be wrong)

Thanks for your help

Update :

I have downgraded my vscode installation to 1.46.1 from 1.47 and it worked so I am certain that something is not right with vscode 1.47

Upvotes: 3

Views: 1999

Answers (1)

TOPKAT
TOPKAT

Reputation: 8638

this seems to be a problem in vsCode like spotted here https://github.com/microsoft/vscode/issues/102042.

To solve it, add those lines to your launch.json config:

"type": "pwa-node",
"resolveSourceMapLocations": [
    "${workspaceFolder}/**",
    "!**/node_modules/**" // this lines prevent reading source maps from node_modules
],

Tell me if it helps :)

Upvotes: 5

Related Questions