源映射在整个应用程序中的vscode(nodemon调试)中不起作用

时间:2017-11-29 13:57:20

标签: visual-studio-code remote-debugging source-maps nodemon node-debugger

我使用vscode(github repo)进行nodemon调试配置。调试时的Sourcemap在地点(快速路线)上不起作用。我想知道为什么会这样:

.vscode / launch.json

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

我的typescipt应用程序:

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;

和tsconfig.json

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

也是我的nodemon命令: nodemon --inspect=18531 dist/index.js 和typescipt命令: tsc -w

我正在跑步: - Windows 10企业版 - nodejs:9.2.0 - nodemon:1.12.1

1 个答案:

答案 0 :(得分:0)

好的,不管怎样,这对我的MacOSX上的 nodejs 9.2.0 没有问题: 的 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
    }
}