Node 0.5.10-pre 下抑制了 CoffeeScript 编译器错误

发布于 2024-12-10 13:03:15 字数 796 浏览 0 评论 0原文

当我的脚本因任何原因无法解析时,我会从编译器获得堆栈跟踪,但根本无法了解脚本中问题所在的位置:

mpurvis@citadel:~/coffee$ coffee -c Test.coffee

/usr/local/lib/node_modules/coffee-script/lib/command.js:15
    return process.binding('stdio').writeError(line + '\n');
                   ^
Error: No such module
    at /usr/local/lib/node_modules/coffee-script/lib/command.js:15:20
    at /usr/local/lib/node_modules/coffee-script/lib/command.js:167:7
    at /usr/local/lib/node_modules/coffee-script/lib/command.js:115:26
    at [object Object].<anonymous> (fs.js:108:5)
    at [object Object].emit (events.js:64:17)
    at afterRead (fs.js:1074:12)
    at Object.wrapper [as oncomplete] (fs.js:246:17)

目前,它只是一个用于尝试系统的玩具脚本,因此我可以通常只是进行试验,直到它再次起作用,但这对于任何大小的文件都是不可能的。是否有一些我没有看到的技巧来获取发生错误的行?

谢谢!

When my script fails to parse for any reason, I get a stack trace from the compiler, with no insight at all into where in my script the problem lies:

mpurvis@citadel:~/coffee$ coffee -c Test.coffee

/usr/local/lib/node_modules/coffee-script/lib/command.js:15
    return process.binding('stdio').writeError(line + '\n');
                   ^
Error: No such module
    at /usr/local/lib/node_modules/coffee-script/lib/command.js:15:20
    at /usr/local/lib/node_modules/coffee-script/lib/command.js:167:7
    at /usr/local/lib/node_modules/coffee-script/lib/command.js:115:26
    at [object Object].<anonymous> (fs.js:108:5)
    at [object Object].emit (events.js:64:17)
    at afterRead (fs.js:1074:12)
    at Object.wrapper [as oncomplete] (fs.js:246:17)

For now, it's just a toy script to try the system out, so I can usually just experiment until it works again, but that would be impossible in a file of any size. Is there some trick I'm not seeing to get the line where the error occurred?

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

牛↙奶布丁 2024-12-17 13:03:16

Node 的最新版本与 cs 不完全兼容..node_stdio 模块被删除...修复它的简单方法是打开 /usr/local/lib/node_modules/coffee-script/lib/command.js 并更改 第 15 行

process.binding('stdio').writeError(line + '\n'

process.stderr.write(line + '\n')

)总是可以从 github 问题部分获得更多帮助
https://github.com/jashkenas/coffee-script/commit/c77f7737a5d94a05a999109810ea7634f540e1e2

祝你好运,编码愉快

the latest version from node isn't full compatible with cs..the node_stdio module ws removed...a simple way for fix it is open /usr/local/lib/node_modules/coffee-script/lib/command.js and change the line 15

process.binding('stdio').writeError(line + '\n')

for

process.stderr.write(line + '\n')

always you can get more help from github issues section
https://github.com/jashkenas/coffee-script/commit/c77f7737a5d94a05a999109810ea7634f540e1e2

good luck and happy coding

终遇你 2024-12-17 13:03:16

这看起来不像语法问题。该错误来自 command.js,它定义了 coffee 命令行实用程序。如果是编译器错误,则可能来自于 coffee-script.js

那么为什么 command.js 中的 process.binding('stdio') 位失败了呢?我能想到两种可能性:

  1. 您正在使用一种奇怪的 shell(或配置奇怪的 shell),它与 Node 的 stdio 版本不能很好地配合。这似乎不太可能,但有可能......
  2. 您使用的是 CoffeeScript 目前不兼容的 Node.js 版本。当你执行node -v时你会得到什么?最安全的选择是最新的 0.4.x,因为它们是稳定版本(0.5.x 是实验性的)。

This doesn't look like a syntax issue. The error is coming from command.js, which is what defines the coffee command-line utility. If it were a compiler error, it would be from coffee-script.js.

So why is the process.binding('stdio') bit in command.js failing? There are two possibilities I can think of:

  1. You're using a weird shell (or a weirdly configured one) that doesn't play nice with Node's version of stdio. This seems unlikely, but it's possible...
  2. You're using a version of Node.js that CoffeeScript isn't currently compatible with. What do you get when you do node -v? Your safest bet is the latest 0.4.x, since those are stable releases (0.5.x is experimental).
另类 2024-12-17 13:03:16

这个问题是很久以前的问题了。

Node 0.6.x 会抛出与 CoffeeScript 1.1.x 类似的错误;升级到 1.3.x 就可以了。

This question is from awhile back.

Node 0.6.x throws a similar error with CoffeeScript 1.1.x; upgrading to 1.3.x does the trick.

习惯成性 2024-12-17 13:03:16

您的系统上可能有 2 个不同的咖啡脚本。检查哪种咖啡,然后找到较旧的咖啡并加冰。我去年夏天安装了一个(v1.1),现在一切都清理干净了。

Likely 2 different coffee-scripts on your system. check which coffee, than track down the older one and ice it. I had one from an install last summer (v1.1), it's all cleared up now.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文