在NWJS中调试节点模块 [英] Debug node modules in nwjs

查看:354
本文介绍了在NWJS中调试节点模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在开发基于节点Webkit(nwjs)的应用程序,它是节点模块和角度代码的混合体.很多业务逻辑已经转移到了节点模块上,但是我还没有找到一种在正在运行的应用程序中调试该代码的方法.

We're developing an application based on node webkit (nwjs) that is a mix of node modules and angular code. A lot of business logic has been moved to the node modules and I haven't found a way to debug that code in the running application.

使用devtools进行调试似乎无效,并且这是已知的局限性或错误(使用devtools进行调试).我什至试图从其中一个脚本中要求node-monkey,希望能够打开某种后门程序;)-不幸的是没有起作用.

Debugging with devtools doesn't seem to work, and that's a known limitation or bug (Debugging with devtools). I even tried to require node-monkey from one of the scripts, hoping to be able to open some sort of backdoor ;) - didn't work unfortunately.

那么还有(远程)调试代码的其他方法或技巧吗?

So is there any other way or trick to (remote) debug the code?

推荐答案

我正在使用Chrome调试器扩展程序在nwjs应用程序中调试节点模块.

I'm using the Chrome Debugger Extension to debug my node modules in my nwjs app.

这是launch.json中的配置:

Here's the config in launch.json:

{
    "name": "Launch nwjs",
    "type": "chrome",
    "request": "launch",
    "webRoot": "${workspaceRoot}/src", //where you put your .js files
    "runtimeExecutable": "nw"
    "runtimeArgs": [
        "${workspaceRoot}",
        "--chrome-remote-port=9222"
    ],
    "sourceMaps": false,
    "diagnosticLogging": true,
    "port": 9222
},

我不得不从VS Code更改一些文件,因为默认情况下编辑器会忽略以chrome-extension://开头的URL,并且Nwjs在此协议下运行您的应用...

I had to change some files from VS Code since the editor ignores URL's that starts with chrome-extension:// by default and the Nwjs runs your app under this protocol...

GitHub上的这个问题对我有很大帮助.

This Issue on GitHub helped me alot.

https://github.com/nwjs/nw.js/issues/4919

这篇关于在NWJS中调试节点模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆