我正在尝试设置VSCode 1.6.1,以便能够调试用CoffeeScript 1.11.1_1编写的Meteor 1.4.1.2应用程序。
在VSCode launch.json文件中,我定义了两个附加配置: - 使用内置节点调试器调试服务器端代码 - 使用chrome调试器扩展
调试客户端代码在调试器语句之后,我在Meteor排行榜示例的代码的所有3个部分中放置了断点:在客户端和服务器上运行的同构部分中,以及仅在客户端和仅服务器中代码的各个部分。
当我在调试器语句上暂停应用程序时附加任一调试器时,断点变为灰色并显示警告:"断点被忽略,因为找不到生成的代码(源映射问题?)"
launch.json文件如下:
{
"version": "0.2.0",
"configurations": [
{
"name": "Launch",
"type": "node",
"request": "launch",
"program": "${workspaceRoot}/leaderboard.coffee",
"stopOnEntry": false,
"args": [],
"cwd": "${workspaceRoot}",
"preLaunchTask": null,
"runtimeExecutable": null,
"runtimeArgs": [
"--nolazy"
],
"env": {
"NODE_ENV": "development"
},
"console": "internalConsole",
"sourceMaps": true,
"outFiles": [
"${workspaceRoot}/.meteor/local/build/programs/server/app/app.js",
"${workspaceRoot}/.meteor/local/build/programs/web.browser/app/app.js"
]
},
{
"name": "Attach Server",
"type": "node",
"request": "attach",
"port": 5858,
"address": "localhost",
"restart": false,
"sourceMaps": true,
"outFiles": ["${workspaceRoot}/.meteor/local/build/programs/server/app/app.js"],
"localRoot": "${workspaceRoot}",
"remoteRoot": null
},
{
"name": "Attach Client",
"type": "chrome",
"request": "attach",
"port": 9222,
"address": "localhost",
"sourceMaps": true
// "url": "//localhost:9222/"
},
{
"name": "Attach to Process",
"type": "node",
"request": "attach",
"processId": "${command.PickProcess}",
"port": 5858,
"sourceMaps": false,
"outFiles": []
}
]
}
源leaderboard.coffee文件如下:
class Player
constructor: (@name, @score = Math.floor(Math.random() * 10)) ->
inc: -> @score = @score + 1
class Leaderboard extends Mongo.Collection
insertNewPlayer: (playerName) ->
player = new Player(playerName)
@insert player
insertPlayers: (playerNames) ->
# @remove({})
@insertNewPlayer(playerName) for playerName in playerNames
self = @
insertRank: =>
sortedPlayers = @find {}, {sort: {score: -1, name: 1}}, {reactive: false}
.fetch()
previousPlayer = sortedPlayers[0]
rank = 1
@update {_id: previousPlayer._id}, {$set: {rank: rank, rankStr: "#{rank}"}}
tiedCounter = 1
for player in sortedPlayers[1..]
do (player) =>
if player.score is previousPlayer.score
tiedCounter = tiedCounter + 1
@update {_id: player._id}, {$set: {rank: rank, rankStr: "-"}}
else
rank = rank + tiedCounter
@update {_id: player._id}, {$set: {rank: rank, rankStr: "#{rank}"}}
previousPlayer = player
self = @
debugger
aflLeaderboard = new Leaderboard("aflLeaderboard") unless aflLeaderboard?
# debugger
if Meteor.isClient
Template.leaderboard.helpers
players: -> aflLeaderboard.find {}, {sort: {score: -1, name: 1}}
#Template.leaderboard.events
# 'click tr#sortButtonRow>th#sortButtonCell>button': leaderboard = players()
Template.player.events
'click tr>td>button': ->
aflLeaderboard.update {_id: player._id}, {$inc: {score: 1}}
# debugger
if Meteor.isServer
Meteor.startup ->
if not (aflLeaderboard? and aflLeaderboard.findOne({})?)
aflLeaderboard.insertPlayers [
"Heath Shaw"
"Alex Rance"
"Easton Wood"
]
aflLeaderboard.insertRank()
self = @
这真的是源地图问题吗? 如果是,我的launch.json文件出了什么问题?
由于
答案 0 :(得分:0)
我认为您需要检查以下两个属性:
"program": "${file}", //important, make sure debug current file
"outFiles": [//important, where to find sourcemap js file
"${workspaceFolder}/dist/api/api.js"
]