Best Practice: is my app running in node-webkit

5 views
Skip to first unread message

Ed Thompson

unread,
Nov 16, 2013, 10:54:50 AM11/16/13
to node-...@googlegroups.com
I have an app that will be running in node-webkit, but also as a packaged app in chromeos.

Is there something I can easily check in javascript to tell me I am running in node-webkit, so I can wrap any conditional code?

Ewald Horn

unread,
Nov 16, 2013, 11:20:08 AM11/16/13
to node-...@googlegroups.com
Hi Ed,

I have something similar and I use the failure / success of  "gui = require('nw.gui');" to determine if I'm running in Node Webkit or not.  From there I set a variable in my application object to whether "gui" is defined or not and use that as a controller for conditional code.

So far it's worked out well for me as it's mostly UI code in my app that's conditional.


On 16 November 2013 17:54, Ed Thompson <ed4b...@gmail.com> wrote:
I have an app that will be running in node-webkit, but also as a packaged app in chromeos.

Is there something I can easily check in javascript to tell me I am running in node-webkit, so I can wrap any conditional code?

--
You received this message because you are subscribed to the Google Groups "node-webkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-webkit...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Ed Thompson

unread,
Nov 16, 2013, 12:12:50 PM11/16/13
to node-...@googlegroups.com
I am considering  if (process) { ...}

Ewald Horn

unread,
Nov 16, 2013, 3:18:28 PM11/16/13
to node-...@googlegroups.com
Could work, I haven't really looked into the process var yet, I must admit.

Alban Read

unread,
Nov 16, 2013, 4:05:15 PM11/16/13
to node-...@googlegroups.com


environment.nodeWebKit = (typeof(process) === 'object' && process.features.uv) ? true : false;
if (environment.nodeWebKit === true) {

Roger

unread,
Nov 17, 2013, 2:57:03 AM11/17/13
to Ed Thompson, node-...@googlegroups.com
Hello,

You can test process.versions['node-webkit']
--
Roger

ims...@gmail.com

unread,
Jan 30, 2014, 1:28:07 AM1/30/14
to node-...@googlegroups.com, Ed Thompson
Why process is undefined? I am using node-webkit on OSX, is the variable name changed?.

ims...@gmail.com

unread,
Jan 30, 2014, 1:48:51 AM1/30/14
to node-...@googlegroups.com, Ed Thompson, ims...@gmail.com
Answer my own question:), the problem is due to I used "http://" protocol, after I have changed to "file://", everything works.

Hugh Isaacs II

unread,
Jan 30, 2014, 2:44:51 PM1/30/14
to node-...@googlegroups.com
I used the app protocol to deal with this issue https://github.com/rogerwang/node-webkit/wiki/App%20protocol

adnan....@gmail.com

unread,
Oct 21, 2014, 5:10:47 PM10/21/14
to node-...@googlegroups.com, ed4b...@gmail.com, ims...@gmail.com
For 'http://' protocol i came with this solution: 0===navigator.plugins.length?!0:!1;
Reply all
Reply to author
Forward
0 new messages