我让iisnode在win8 / IIS8上顺利运行。我创造了一个非常简单的hello世界,它很棒。但是,当我尝试使用process.stdin时,我收到以下错误:
Application has thrown an uncaught exception and is terminated:
Error: Implement me. Unknown stdin file type!
at process.startup.processStdio.process.openStdin [as stdin] (node.js:405:17)
at Object.<anonymous> (C:\ApprendaPlatform\SiteData\developer\v1\root\shim\node_modules\actionhero\bin\zzz.js:7:20)
at Module._compile (module.js:449:26)
at Object.Module._extensions..js (module.js:467:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:362:17)
at require (module.js:378:17)
at Object.<anonymous> (C:\Program Files\iisnode\interceptor.js:210:1)
at Module._compile (module.js:449:26)
请注意,我没有使用process.stdout。
我的代码:
// kaboom!
var breakthings = process.stdin;
// works
// var breakthings = process.stdout;
iisnode是否对stdin做了一些时髦的事情,或者我错误配置了什么?
答案 0 :(得分:1)
在我的情况下,由于问题仍然存在,我只是从iisnode文件中的process.stdin覆盖getter
var events = require('events');
// Define a custom getter for process.stdin since iisnode still didn't fix the bug
process.__defineGetter__('stdin', function(){
return new events.EventEmitter();
})
// no kaboom anymore ;)
var breakthings = process.stdin;
希望这有帮助;)
更新(02-06-2016): 以更加明智和干净的方式:
var events = require('events');
delete process.stdin;
process.stdin = new events.EventEmitter();
// no kaboom anymore ;)
var breakthings = process.stdin;
答案 1 :(得分:0)