console.log()没有出现在我的终端(nwjs)中 [英] console.log() does not appear in my terminal (nwjs)
问题描述
在我的nwjs应用中,我从HTML文件中加载了 _launch.js 文件:
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>
在我的 _launch.js 文件中,我启动了快速服务器和socketIO所需的Node进程.
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/';
});
该应用程序启动正常,我的express/socketIO连接均正常运行.
The app launches just fine, and my express/socketIO connections are all perfectly working.
但是当server.listen()回调中的 console.log()出现在我的终端上时,我尝试从 server.js 文件记录的所有消息(之前需要)永远不会出现在任何地方.
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.
有什么想法吗?
根据nwjs Wiki,通过 require()加载的任何文件都应在Node上下文中运行(否则我的看起来是这样)-但由于任何原因,我不能使用 console.log()查看已记录的信息.
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.