为什么我在cygwin中运行coffee命令时出错?

时间:2013-06-02 01:47:36

标签: windows node.js intellij-idea coffeescript cygwin

我通过使用node-v0.10.9-x64.msi安装程序安装Node.js来跟踪CoffeeScript installation guide。然后我启动了一个cygwin控制台并cd'进入我的.coffee文件的目录。如果我单独输入coffee,它会给我这个错误:

$ coffee
coffee>
events.js:72
        throw er; // Unhandled 'error' event
              ^
Error: read ENOTCONN
    at errnoException (net.js:884:11)
    at Socket._read (net.js:389:21)
    at Socket.Readable.read (_stream_readable.js:320:10)
    at Socket.read (net.js:291:43)
    at new Socket (net.js:185:10)
    at process.stdin (node.js:660:19)
    at new REPLServer (repl.js:132:15)
    at Object.exports.start (repl.js:312:14)
    at Object.module.exports.start (C:\Users\foo\AppData\Roaming\npm\node_modules\coffee-script\lib\coffee-script\repl.js:106:23)
    at Object.exports.run (C:\Users\foo\AppData\Roaming\npm\node_modules\coffee-script\lib\coffee-script\command.js:77:32)
    at Object.<anonymous> (C:\Users\foo\AppData\Roaming\npm\node_modules\coffee-script\bin\coffee:7:41)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Function.Module.runMain (module.js:497:10)
    at startup (node.js:119:16)
    at node.js:901:3

如果我使用-lw运行命令,则会出现此错误:

$ coffee -lw Example.js.coffee
Error: This socket is closed.
    at Socket._write (net.js:618:19)
    at doWrite (_stream_writable.js:219:10)
    at writeOrBuffer (_stream_writable.js:209:5)
    at Socket.Writable.write (_stream_writable.js:180:11)
    at Socket.write (net.js:596:40)
    at lint (C:\Users\foo\AppData\Roaming\npm\node_modules\coffee-script\lib\coffee-script\command.js:468:15)
    at compileScript (C:\Users\foo\AppData\Roaming\npm\node_modules\coffee-script\lib\coffee-script\command.js:193:18)
    at C:\Users\foo\AppData\Roaming\npm\node_modules\coffee-script\lib\coffee-script\command.js:144:18
    at fs.js:266:14
    at Object.oncomplete (fs.js:107:15)

events.js:72
        throw er; // Unhandled 'error' event
              ^
Error: spawn ENOENT
    at errnoException (child_process.js:980:11)
    at Process.ChildProcess._handle.onexit (child_process.js:771:34)

如果我只使用-l选项运行,则会出现此错误:

$ coffee -l Example.coffee
Error: This socket is closed.
    at Socket._write (net.js:618:19)
    at doWrite (_stream_writable.js:219:10)
    at writeOrBuffer (_stream_writable.js:209:5)
    at Socket.Writable.write (_stream_writable.js:180:11)
    at Socket.write (net.js:596:40)
    at lint (C:\Users\foo\AppData\Roaming\npm\node_modules\coffee-script\lib\coffee-script\command.js:468:15)
    at compileScript (C:\Users\foo\AppData\Roaming\npm\node_modules\coffee-script\lib\coffee-script\command.js:193:18)
    at C:\Users\foo\AppData\Roaming\npm\node_modules\coffee-script\lib\coffee-script\command.js:144:18
    at fs.js:266:14
    at Object.oncomplete (fs.js:107:15)

但似乎我可以在没有lint选项的情况下编译和/或观看选项,并且事情按预期工作。

我对Node.js一无所知。我试过谷歌搜索这些错误,我看到与使用中的端口和套接字问题相关的类似错误。我认为注意我使用Intellij IDEA(一个IDE)并且它有一个可能干扰的CoffeeScript插件可能是有用的。但是当我关闭Intellij时,我仍然会得到同样的错误,这可能是一个红色的鲱鱼。

另外,也许有一个特定的cygwin版本的node.js我应该安装而不是我从安装说明中获得的那个?

如果我自己输入node,就会说:

$ node

events.js:72
        throw er; // Unhandled 'error' event
              ^
Error: read ENOTCONN
    at errnoException (net.js:884:11)
    at Socket._read (net.js:389:21)
    at Socket.Readable.read (_stream_readable.js:320:10)
    at Socket.read (net.js:291:43)
    at new Socket (net.js:185:10)
    at process.stdin (node.js:660:19)
    at startup (node.js:145:16)
    at node.js:901:3

1 个答案:

答案 0 :(得分:1)

不幸的是,node no longer supports Cygwin

一种解决方法是使用各种MSysGit作为控制台而不是Cygwin,至少对于运行node / coffeescript。 Git Bash提供了一个很好的。你可以得到它here