【问题标题】:Why am I getting errors running the coffee command in cygwin?为什么我在 cygwin 中运行 coffee 命令时出错?
【发布时间】:2015-07-21 23:43:45
【问题描述】:

我按照CoffeeScript installation guide 安装了带有node-v0.10.9-x64.msi 安装程序的Node.js。然后我启动了一个 cygwin 控制台并将cd'd 放入带有我的.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 选项的情况下编译和/或 watch 选项,并且事情按预期工作。

我对 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

【问题讨论】:

  • 没有 cygwin 是否会出现同样的错误?
  • @user568109 是的。
  • 如果你自己输入node会发生什么?
  • @user568109 查看我的编辑底部
  • 您的节点安装看起来已损坏。可能是 0.10.9 版本中的错误。尝试重新安装它,如果它仍然在此处给出错误文件问题 - github.com/joyent/node/issues

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


【解决方案1】:

很遗憾,node no longer supports Cygwin

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

【讨论】: