Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
53
rated 0 times [  55] [ 2]  / answers: 1 / hits: 18349  / 9 Years ago, tue, april 7, 2015, 12:00:00

In my nwjs app, I load a _launch.js file from an HTML file:



<html>
<body>
<script type=text/javascript src=_launch.js></script>
</body>
</html>


And in my _launch.js file, I fire up the the Node processes I need for an express server and socketIO.



var express = require('express'),
app = express(),
server = require('http').Server(app),
io = require('socket.io')(server),
gui = require('nw.gui'),

__curDir = process.cwd(),

//keep the logic for the IO connections separate
ioServer = require(__curDir + '/server.js');

//configure Express to default web requests to /workspace/ folder
app.use(express.static(__curDir + '/workspace'));

ioServer.init(io, console);

server.listen(3000, function () {
console.log('HTTP server listening on *:3000');
window.location = 'http://localhost:3000/MyApp/';
});


The app launches just fine, and my express/socketIO connections are all perfectly working.



But while the console.log() in the server.listen() callback appears in my terminal, any messages I try to log from the server.js file (required earlier) never show up anywhere.



Any ideas why?



Per the nwjs wiki, any files loaded via require() should be running in the Node context (and mine otherwise appears to be) -- but for whatever reason, I cannot use console.log() to view logged information.


More From » node.js

 Answers
44

Please look at the list of changes related to node in the nw.js wiki.




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).



[#67161] Monday, April 6, 2015, 9 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
coleman

Total Points: 518
Total Questions: 81
Total Answers: 96

Location: Aland Islands
Member since Wed, Nov 17, 2021
3 Years ago
;