0

relay-starter-kit 使用 babel-node 运行 ES6 风格的 JavaScript。

我想调试像 database.js 和 schema.js 这样的服务器端代码。

我尝试了 node.js 远程调试,但无法在我的任何断点处停止。我还尝试了不同的启用调试方式,例如babel-node --debug ./server.js. 但到目前为止没有任何效果。我想我必须以某种方式告诉 babel 使用源映射生成可调试输出?

更准确地说,例如,我getUser该如何调试?database.js

谢谢

4

1 回答 1

2

插入调试器语句

mutateAndGetPayload: ({id, text}) => {
  debugger;
  /* ... */
},

使用调试器运行服务器

$ ./node_modules/.bin/babel-node debug ./server.js
< Debugger listening on port 5858
debug> . ok
break in node_modules/babel/lib/_babel-node.js:1
> 1 "use strict";
  2 
  3 // istanbul ignore next
debug> c
< GraphQL Server is now running on http://localhost:8080
< Relay TodoMVC is now running on http://localhost:3000
break in data/schema.js:278
 276     var text = _ref11.text;
 277 
>278     debugger;
 279     var localTodoId = (0, _graphqlRelay.fromGlobalId)(id).id;
 280     (0, _database.renameTodo)(localTodoId, text);
debug> 
于 2015-09-15T07:11:54.920 回答