Changes to Node {: .doctitle}
console
Since NW.js 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 the console of Chromium. You may see it in your “Developer Tools” window (on its “Console” tab).
process
A couple of new fields is added to the global process
object:
process.versions['nw']
is set with NW.js’s version.process.versions['chromium']
is set with the chromium version which NW.js is based on.process.versions['nw-flavor']
is set to ‘sdk’ when the binary is SDK build, or ‘normal’ when the binary is normal build.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.
require
Behaviour of relative paths in Node’s require()
method depends on the JavaScript context in which the parent file is running in. (where “the parent file” is the file in which the require()
method is called):
- If the parent file is running in Node context, the child’s relative path is treated as relative to its parent.
- If the parent file is running in browser context, the child’s relative path is treated as relative to the application’s root directory, i.e. the directory of manifest file.