使用Webstorm调试Nodewebkit [英] Debugging Nodewebkit with Webstorm

查看:149
本文介绍了使用Webstorm调试Nodewebkit的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在Webstorm中打开NW,以便可以开始调试.当我在应用程序中遇到错误时,NW窗口将关闭,而没有任何提示原因.

I am trying to open a NW in a Webstorm so I can start debugging. When I have erro r in the App, NW windows just closes without any hint why that happened.

我已经找到了这个文章在Webstorm网站上.在我的根文件夹中,我有一个app.js,其中包含常用的快速应用启动和模块包含.我也有package.json:

I have found this article on the Webstorm website. In my root folder I have app.js that contains usual express app start up and module inclusion. Also I have package.json:

{
  "name": "nw",
  "version": "1.0.0",
  "description": "",
  "main": "index.html",
  "node-main": "app.js",
  "scripts": {
  "test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"window": {
"toolbar": true,
"width": 800,
"height": 500
},
 "license": "ISC",
 "dependencies": {
 "jquery": "^2.1.4",
 "nw": "^0.12.2",
 "pretty-bytes": "^1.0.2"
  }
}

我有以下index.html文件:

And I have the following index.html file:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>My App</title>
<script src="app.js" type="text/javascript"></script>
</head>
<body>
<script type="text/javascript">
window.location = 'http://localhost:3000';
</script>
</body>
</html>

我对此有两个问题:

  1. 当我单独运行NW(只需双击nw.exe)时,应用程序将启动,但并非总是启动.在10倍,它将关闭3倍.其余的将正常打开.

  1. When I run NW alone (just double click the nw.exe), app will launch, but not always. in 10 times, it will just close 3 times. The rest will open normally.

我已经按照Webstorm网站上的说明进行调试,但结果却很奇怪.当我尝试在webstorm中打开它时,NE窗口显示,并因以下错误而立即关闭:进程结束,退出代码为0 但是我可以以普通模式(不是debugg)在webstorm中打开应用程序.

I have followed instruction on the Webstorm site how to debug it, and with strange results. When I try to open it inside webstorm, NE window shows, and imidiately closes with this error: Process finished with exit code 0 But I can open the applicaiton in the webstorm in normal mode (not debugg).

这是怎么回事? 我的Webstorm调试屏幕:

What is going on in here? My Webstorm debug screen:

推荐答案

您没有发布任何代码,但是您可能会收到一个异常,该异常会使应用立即崩溃.

you didn't post any of your code, but you probably get an exception that makes the app crash immediately.

根据过去的经验,最常见的异常是由于对窗口的错误调用导致的:

From past experience the most common exception is caused due to incorrect call to window:

窗口:定义为全局"属性,指向DOM窗口 全局对象.请注意,它将在页面导航时更新. 该符号在脚本加载时不可用,因为 在DOM窗口加载之前执行脚本()

window: defined as a property of 'global', points to the DOM window global object. Note that it would be updated upon page navigation. This symbol is not available at the time the script is loaded, because the script is executed before the DOM window load (source)

因此,如果您使用"node-main",然后在其中使用"window",则您的应用程序将在启动时崩溃.在app.js中查找对window的任何调用,然后尝试对其进行注释.如果可行,则需要将代码放入函数中,然后从index.html调用它们.

So if you use 'node-main' and in there you use 'window' your app will crash on startup. Look for any call to window in app.js and try to comment it. if it works - you need to put the code in functions and call them from index.html.

如果不是这种情况,则需要调试代码以查找其中断原因.尝试省略代码块以查找错误.您可以发布代码以获取更多帮助.

if this is not the case, you need to debug your code to find why it breaks. try omitting code blocks to find the bug. you can post your code for more help.

这篇关于使用Webstorm调试Nodewebkit的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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