【问题标题】:Source map doesn't work in vscode (nodemon debugging) in entire application源映射在整个应用程序的 vscode(nodemon 调试)中不起作用
【发布时间】:2018-05-13 06:21:10
【问题描述】:

我有使用 vscode (github repo) 的 nodemon 调试配置。调试时的源图不起作用,除非在地方(快速路线)。我想知道为什么会这样:

.vscode/launch.json

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

我的打字申请:

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 和 typecipt 命令: tsc -w

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

【问题讨论】:

  • 当你说“源地图不起作用”时,你能更具体一点吗

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


【解决方案1】:

好的,这在我的带有 nodejs 9.2.0 的 MacOSX 上运行没有问题: 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
    }
}

【讨论】:

  • 在 Windows 上也可以工作...这是 Visual Studio Code 1.19.0 Insider 错误。
猜你喜欢
  • 2017-03-16
  • 1970-01-01
  • 2018-05-27
  • 2017-03-22
  • 2016-07-27
  • 2021-01-13
  • 2020-05-28
  • 2016-07-06
  • 1970-01-01
相关资源
最近更新 更多