casperjs无法运行CoffeeScript脚本

jba*_*ias 8 coffeescript phantomjs casperjs

我第一次安装了casperjs并运行了示例脚本.第一个示例脚本(javascript)没有发生任何事故.然后我尝试运行coffescript样本,我更喜欢,并收到以下错误:

无法加载脚本test.coffee; 检查文件语法

我搜索了一个答案,唯一相关问题的解决方案对我不起作用.我能够将CoffeeScript(test.coffee)编译成JavaScript(test.js),然后再次运行已编译的JavaScript,而不是下载.

我试图通过在casperjs文件中搜索错误消息来追踪错误.我在〜/ .node/lib/node_modules/casperjs/bin/bootstrap.js文件的末尾找到了错误消息,它将控制传递给phantomjs.我创建了一个简单的CoffeeScript:test_phantomjs.coffee:

console.log "hello phantomjs"
phantom.exit()
Run Code Online (Sandbox Code Playgroud)

并使用以下结果运行脚本(phantomjs test_phantomjs.coffee):

无法打开'test_phantomjs.coffee'

在这一点上,我很茫然.由于编译成JavaScript解决了这个问题,因此问题比任何事情都更加不方便.他们是我缺少的东西吗?

Jak*_*aur 0

对我有用。您能发布您的 PhantomJS 版本和平台吗?

我的在 Mac OS X 上:

$ phantomjs -v
1.9.8
Run Code Online (Sandbox Code Playgroud)

正常工作:

$ phantomjs test_phantomjs.coffee 
hello phantomjs
Run Code Online (Sandbox Code Playgroud)