Source map doesn't work in vscode (nodemon debugging) in entire application

1.8k views Asked by At

I have nodemon debug configuration with vscode (github repo) . Sourcemap while debugging doesn't work excepts on place (express route). I am wondering why is that :

.vscode/launch.json

{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "node",
            "request": "attach",
            "name": "Quick Attach",
            "port": 18531,
            "sourceMaps": true,
            "address": "localhost",
            "restart": true
        }
    ]
}

My typescipt application:

import * as http from 'http';
import * as url from 'url';
import * as express from 'express';
import * as bodyParser from 'body-parser';
import errorHandler = require('errorhandler');
import methodOverride = require('method-override');
const cors = require('cors');
const app = express();
let port: number = 3000;
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json());
app.use(methodOverride());
app.use(errorHandler());
app.use(cors());

app.get('/test', (req, res) => {
    res.send('hello') // SOURCE MAP WORKS ONLY HERE
});

app.listen(port, function () {
    console.log('Server listening on port %d in %s mode', port, app.settings.env);
});

export var App = app;

and tsconfig.json

{
    "compileOnSave": true,
    "compilerOptions": {
      "declaration": false,
      "experimentalDecorators": true,
      "emitDecoratorMetadata": true,
      "outDir": "./dist",
      "sourceMap": true,
      "skipLibCheck": true
    },
    "files": [
      "index.ts"
    ]
  }

also my nodemon command: nodemon --inspect=18531 dist/index.js and typescipt command: tsc -w

I am running: - Windows 10 Enterprise - nodejs: 9.2.0 - nodemon: 1.12.1

1

There are 1 answers

1
Dariusz Filipiak On

OK somehow this is working on my MacOSX with nodejs 9.2.0 without problems: launch.json

{
    "type": "node",
    "request": "launch",
    "remoteRoot": "${workspaceRoot}/dist",
    "name": "Lanuch full nodemon",
    "runtimeExecutable": "nodemon",
    "program": "${workspaceFolder}/dist/index.js",
    "restart": true,
    "sourceMaps": true,
    "console": "internalConsole",
    "internalConsoleOptions": "neverOpen"
}

tsconfig.json

{
    "compileOnSave": true,
    "compilerOptions": {
      "declaration": false,
      "experimentalDecorators": true,
      "emitDecoratorMetadata": true,

      "watch": true,
      "outDir": "./dist",
      "rootDir": "./",
      "sourceMap": true,
      "skipLibCheck": true
    }
}