1

我按照CoffeeScript 安装指南使用安装程序安装node-v0.10.9-x64.msiNode.js。然后我启动了一个 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 选项的情况下编译和/或 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
4

1 回答 1

1

不幸的是,节点不再支持 Cygwin

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

于 2015-07-21T15:43:45.443 回答