我有带有 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