2016-11-15 73 views
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 
+0

我剛開始使用這個今天,並得到了同樣的錯誤。谷歌搜索visual studio代碼「調試適配器中未處理的錯誤:」顯示這是唯一的結果,我想知道是否有更新的擴展打破了什麼? – silencedmessage

+0

很高興我不是唯一一個這樣的人。也許這是對錯誤起源的暗示? (來自插件幫助部分):「仔細查看你的sourcemap配置,sourcemap有一個到源文件的路徑,這個擴展名使用這個路徑來找到磁盤上的原始源文件,檢查你的sourcemap中的sourceRoot和sources屬性並確保它們可以與啓動配置中的webRoot屬性結合使用,以構建原始源文件的正確路徑。「 –

+1

如果我理解這個權利,您可以使用https://github.com/hbenl/vscode-firefox-debug調試相同的代碼,但不能使用https://github.com/Microsoft/vscode-chrome-debug?這可能是源代碼映射問題或Chrome調試器擴展的問題。您是否通過vscode chrome debugger github問題進行搜索? – Steffen

回答

0

這是一個答案。如果您使用上述配置,則可以在Chrome中使用node.js。感謝開發者的快速修復。

相關問題