1
我想使用vs代码的调试扩展来在chrome中调试我的Typescript代码。作为web服务器,我使用nodejs(也作为VS代码插件)。当我与Firefox这样做,我的断点被击中,因此,当我使用铬我收到以下错误信息:使用node.js使用chrome调试VSCode中的Typescript
******** Unhandled error in debug adapter: TypeError: Path must be a string. Received null
at assertPath (path.js:7:11)
at Object.dirname (path.js:697:5)
at Object.resolveMapPath (C:\Users\pazureck\.vscode\extensions\msjsdiag.debugger-for-chrome-2.2.2\node_modules\vscode-chrome-debug-core\out\src\sourceMaps\sourceMapUtils.js:106:96)
at getSourceMapContent (C:\Users\pazureck\.vscode\extensions\msjsdiag.debugger-for-chrome-2.2.2\node_modules\vscode-chrome-debug-core\out\src\sourceMaps\sourceMapFactory.js:71:30)
at Object.getMapForGeneratedPath (C:\Users\pazureck\.vscode\extensions\msjsdiag.debugger-for-chrome-2.2.2\node_modules\vscode-chrome-debug-core\out\src\sourceMaps\sourceMapFactory.js:29:30)
at SourceMaps.processNewSourceMap (C:\Users\pazureck\.vscode\extensions\msjsdiag.debugger-for-chrome-2.2.2\node_modules\vscode-chrome-debug-core\out\src\sourceMaps\sourceMaps.js:63:32)
at BaseSourceMapTransformer.scriptParsed (C:\Users\pazureck\.vscode\extensions\msjsdiag.debugger-for-chrome-2.2.2\node_modules\vscode-chrome-debug-core\out\src\transformers\baseSourceMapTransformer.js:189:37)
at ChromeDebugAdapter.onScriptParsed (C:\Users\pazureck\.vscode\extensions\msjsdiag.debugger-for-chrome-2.2.2\node_modules\vscode-chrome-debug-core\out\src\chrome\chromeDebugAdapter.js:314:56)
at Client.chrome.Debugger.onScriptParsed.params (C:\Users\pazureck\.vscode\extensions\msjsdiag.debugger-for-chrome-2.2.2\node_modules\vscode-chrome-debug-core\out\src\chrom[...]
这里是我的launch.json:
{
"version": "0.2.0",
"configurations": [
{
"name": "Launch Firefox index.html (sourcemaps)",
"type": "firefox",
"url": "http://localhost:8080/index.html",
"webRoot": "${workspaceRoot}",
"request": "launch"
},
{
"name": "Launch Chrome with sourcemaps",
"type": "chrome",
"request": "launch",
"url": "http://localhost:8080/index.html",
"sourceMaps": true,
"webRoot": "${workspaceRoot}"
},
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"sourceMaps": true,
"program": "${workspaceRoot}/server.js",
"cwd": "${workspaceRoot}",
"outFiles": ["${workspaceRoot}/**/*.js"]
},
// Composite Launches *********************************************************************************************************
{
"name": "Launch Node.js with FF",
"type": "composite",
"configurationNames": [
"Launch Program", "Launch Firefox index.html (sourcemaps)"
],
"request": "launch"
},
{
"name": "Launch Node.js with Chrome",
"type": "composite",
"configurationNames": [
"Launch Program", "Launch Chrome with sourcemaps"
],
"request": "launch"
}
]
}
这里是我的服务器.js
var express = require('express'),
app = express(),
compression = require('compression'),
open = require('open'),
serveIndex = require('serve-index'),
port = process.env.PORT || 8080,
publicPath = '',
directory = __dirname + publicPath,
launchUrl = 'http://localhost:' + port + publicPath,
year = 60 * 60 * 24 * 365 * 1000;
// use compress middleware to gzip content
app.use(compression());
// set default mime type to xml for ".library" files
express.static.mime.default_type = "text/xml";
// serve up content directory showing hidden (leading dot) files
app.use(publicPath, express.static(directory, { maxAge: year, hidden: true }));
// enable directory listing
app.use("/", serveIndex(__dirname, {'icons': true}));
app.use(express.static(directory, { 'dotfiles': 'allow' }));
// start server
app.listen(port);
// launch uri in default browser
// open(launchUrl);
// log to server console
console.log("OpenUI5 SDK server running at\n => " + launchUrl + " \nCTRL + C to shutdown");
看来我做错了发布映射文件,因为Chrome似乎没有找到它们?我也没有得到任何有用的通过谷歌有关我的节点调试配置outFiles
。
有没有人有提示,如何解决这个问题或为什么铬调试适配器接收路径为null?它正在启动并打开给定的地址。
谢谢您的输入!
编辑:
这也是JS控制台上即将在我的情况下发生错误之前:
Tue, 15 Nov 2016 20:34:41 GMT send deprecated hidden: use dotfiles: 'allow' instead at node_modules\serve-static\index.js:96:18
我刚开始使用这个今天,并得到了同样的错误。谷歌搜索visual studio代码“调试适配器中未处理的错误:”显示这是唯一的结果,我想知道是否有更新的扩展打破了什么? – silencedmessage
很高兴我不是唯一一个这样的人。也许这是对错误起源的暗示? (来自插件帮助部分):“仔细查看你的sourcemap配置,sourcemap有一个到源文件的路径,这个扩展名使用这个路径来找到磁盘上的原始源文件,检查你的sourcemap中的sourceRoot和sources属性并确保它们可以与启动配置中的webRoot属性结合使用,以构建原始源文件的正确路径。“ –
如果我理解这个权利,您可以使用https://github.com/hbenl/vscode-firefox-debug调试相同的代码,但不能使用https://github.com/Microsoft/vscode-chrome-debug?这可能是源代码映射问题或Chrome调试器扩展的问题。您是否通过vscode chrome debugger github问题进行搜索? – Steffen