-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Changes related to node
Mithgol edited this page May 7, 2013
·
16 revisions
This document is still under construction
Since node-webkit supports GUI applications instead of console applications, the output of console.log()
(and other similar methods such as console.warn()
and console.error()
) is redirected to WebKit's console. You may see it in your “Developer Tools” window (on its “Console” tab).
A couple of new fields is added to the global process
object:
-
process.versions['node-webkit']
is set with node-webkit's version. -
process.mainModule
is set for the start page (such asindex.html
) as specified in the manifest'smain
field. However, when thenode-main
field is also specified in the manifest,process.mainModule
points to the file specified in thenode-main
field.
The following names are inserted to the global object in Node's context:
-
require
- this is therequire()
function within the main module.
Behaviour of relative paths in Node's require()
method depends on how the parent file is used in the application (where “the parent file” is the file in which the require()
method is called):
- If the parent file was also required by Node (using
require()
), then the child's relative path is treated as relative to its parent. - If the parent file is included by WebKit (using any web technology: classic DOM
window.open()
, node-webkit'sWindow.open()
, classic DOMXMLHttpRequest
, jQuery's$.getScript()
, HTML<script src="...">
element, etc.), then the child's relative path is treated as relative to the application's root directory.