简体   繁体   English

Windows中的“未知的stdin文件类型”错误

[英]'Unknown stdin file type' error in windows

I've been struggling with this errors for 2 days and can't realize why electron renderer process.stdin fails in windows os. 我一直在努力解决这个错误2天,并且无法理解为什么电子渲染器process.stdin在Windows操作系统中失败。

How to reproduce: 如何重现:

type npm install devtool -g then type devtool inside the console type process.stdin and there will be an error message will be two errors, one at line 127 and the other at line 128 at C:\\Users\\rafael\\AppData\\Roaming\\npm\\node_modules\\devtool\\node_modules\\electron-prebuilt\\dist\\resources\\atom.asar\\renderer\\lib\\init.js (devtool update 2.x) 键入npm install devtool -g然后在控制台类型process.stdin键入devtool 将会出现两个错误,一个在第127行,另一个在第128行在C:\\ Users \\ rafael \\ AppData \\ Roaming \\ npm \\ node_modules \\ devtool \\ node_modules \\ electron-prebuilt \\ dist \\ resources \\ atom.asar \\ renderer \\ lib \\ init.js (devtool update 2.x)

Error: Implement me. Unknown stdin file type!

C:\\Users\\rafael\\AppData\\Roaming\\npm\\node_modules\\devtool\\node_modules\\electron-prebuilt\\dist\\resour…:127 Error: Implement me. Unknown stdin file type!(…)(anonymous function) @ C:\\Users\\rafael\\AppData\\Roaming\\npm\\node_modules\\devtool\\node_modules\\electron-prebuilt\\dist\\resour…:127Module._compile @ module.js:425Module._extensions..js @ module.js:432Module.load @ module.js:356Module._load @ module.js:313Module.runMain @ module.js:457startup @ node.js:151(anonymous function) @ node.js:1007 C:\\Users\\rafael\\AppData\\Roaming\\npm\\node_modules\\devtool\\node_modules\\electron-prebuilt\\dist\\resour…:128 Error: Implement me. Unknown stdin file type! at process.stdin (node.js:747) at hookProcess (C:\\Users\\rafael\\AppData\\Roaming\\npm\\node_modules\\devtool\\lib\\preload.js:117) at C:\\Users\\rafael\\AppData\\Roaming\\npm\\node_modules\\devtool\\lib\\preload.js:29 at Object.<anonymous> (C:\\Users\\rafael\\AppData\\Roaming\\npm\\node_modules\\devtool\\lib\\preload.js:129) at Module._compile (module.js:425) at Object.Module._extensions..js (module.js:432) at Module.load (module.js:356) at Function.Module._load (module.js:313) at Module.require (module.js:366) at require (module.js:385)(anonymous function) @ C:\\Users\\rafael\\AppData\\Roaming\\npm\\node_modules\\devtool\\node_modules\\electron-prebuilt\\dist\\resour…:128Module._compile @ module.js:425Module._extensions..js @ module.js:432Module.load @ module.js:356Module._load @ module.js:313Module.runMain @ module.js:457startup @ node.js:151(anonymous function) @ node.js:1007

I encountered the same problem. 我遇到了同样的问题。

First I thought that devtool as REPL does not need stdin and was a simple bug in windows build. 首先我认为devtool作为REPL不需要stdin,并且是windows build中的一个简单bug。 GitHub repo owners fix it just ignoring stdin on startup but, as you had discovered, devtool is broken and you can not do anything with stdin in windows. GitHub repo所有者修复它只是在启动时忽略stdin但是,正如你所发现的那样,devtool已经坏了,你无法在windows中对stdin做任何事情。

As a proof of concept I create a simple example beyond devtool REPL: 作为概念证明,我创建了一个超出devtool REPL的简单示例:

This piece of code does not work. 这段代码不起作用。

//test.js
var readline = require('readline');
var rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout,
  terminal: true
});

rl.on('line', function(line){
    console.log(line);
})

devtool test.js < input.txt devtool test.js <input.txt

Error: Implement me. Unknown stdin file type!

Windows 7 x64, SO Admin rights, Node v5.10.0, npm v3.8.3 DevTool v1.9.1. Windows 7 x64,SO管理员权限,Node v5.10.0,npm v3.8.3 DevTool v1.9.1。

I had left a comment in your github issue but is closed so I opened a new one . 我在你的github 问题上留了一个评论,但是关闭了,所以我开了一个新评论

There is another question pointing to the same problem. 还有另一个问题指向同一个问题。 One of the comments states that it's a known iisnode issue and also suggests a work around by wrapping all calls to process.stdin like: 其中一条评论声明它是一个已知的iisnode问题 ,并建议通过将所有调用包装到process.stdin例如:

if(!process.env.IISNODE_VERSION) { 
    // do stuff with process.stdin 
}

It can be a temporary solution. 它可以是一个临时解决方案。 I'm sure you've already taken a look to that post, what do you think? 我相信你已经看了那篇文章,你怎么看?

Reading through the libuv source code which is what nodejs uses for certain low-level operations, seems that the reason is that the type of buffer or handle cannot be determined specifically for windows. 通过libuv源代码读取,这是nodejs用于某些低级操作的,似乎原因是无法专门为windows确定缓冲区或句柄的类型。 The GetFileType function seems to return an unknown handle. GetFileType函数似乎返回一个未知句柄。

This is definitely a windows only issue because the part of the library that determines the type of handle is within src/win/handle.c of the UV source code so I don't think this affects *NIX OS'es indeed. 这绝对是一个Windows唯一的问题,因为确定句柄类型的库部分在UV源代码的src/win/handle.c中,所以我认为这不会影响* NIX OS'。

Maybe the installed nodejs version is missing a build-time option? 也许已安装的nodejs版本缺少构建时选项?

A super simple workaround would be to just force devtool to run in its own console window. 一个非常简单的解决方法是强制devtool在自己的控制台窗口中运行。

So instead of running: 所以不是运行:

devtool

Run this: 运行这个:

start devtool

It should pop up in a new window and not be confused about the input pipe. 它应该弹出一个新窗口,不要混淆输入管道。

The same trick works with a lot of Node packages. 同样的技巧适用于很多Node包。

I've had this error when trying to start electron up from a console window; 尝试从控制台窗口启动电子时,我遇到了这个错误; it was odd because it had been working fine. 这很奇怪,因为它一直很好。 I have realised today that the only thing I changed was to launch a terminal window from Visual Studio Code (with add-on). 我今天意识到,我唯一改变的是从Visual Studio Code(附加组件)启动一个终端窗口。

If I use a Terminal created from VS Code (terminal addon) then when I try to run node_modules\\.bin\\electron I get: 如果我使用从VS Code(终端插件)创建的终端,那么当我尝试运行node_modules\\.bin\\electron我得到:

d:\Code\Applications\Example>"node_modules\.bin\electron"
internal/process/stdio.js:86
        throw new Error('Implement me. Unknown stdin file type!');
        ^

Error: Implement me. Unknown stdin file type!
    at process.stdin (internal/process/stdio.js:86:15)
    at startup (node.js:198:18)
    at node.js:457:3

if I make a console window directly in Explorer, it works perfectly fine. 如果我直接在资源管理器中创建一个控制台窗口,它可以正常工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM