Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

casperjs unable to run CoffeeScript scripts

I installed casperjs for the first time and ran the sample scripts. The first sample script (javascript) ran without incident. Then i tried running a coffescript sample, which I prefer, and received the following error:

Unable to load script test.coffee; check file syntax

I searched for an answer and the solution in the only related issue didn't work for me. I was able to compile the CoffeeScript (test.coffee) into JavaScript (test.js) and then ran the compiled JavaScript, again, without indecent.

I tried to track down the error by searching for the error message in the casperjs files. I found the error message at the end the ~/.node/lib/node_modules/casperjs/bin/bootstrap.js file where it passes control to phantomjs. I created simple a CoffeeScript: test_phantomjs.coffee:

console.log "hello phantomjs"
phantom.exit()

and ran the script (phantomjs test_phantomjs.coffee) with the following result:

Can't open 'test_phantomjs.coffee'

At this point I'm at loss. The problem is more of an inconvenience than anything since compiling into JavaScript solves the issue. Is their something I'm missing?

like image 251
jbastias Avatar asked Apr 16 '14 19:04

jbastias


2 Answers

In Phantomjs2.0 was removed support of coffee-script

https://github.com/ariya/phantomjs/issues/12410

like image 158
RDPanek Avatar answered Sep 23 '22 02:09

RDPanek


(disclaimer: i'm/was part of contribution team) the support of coffee script in CasperJS depends on the version of phantomJs you are using because this is phantomjs that provide coffee script support out of box.

You can also use and install slimerjs (https://slimerjs.org) which - from my point of view - is more performant than phantomjs and supports coffeescript scripts.

Mickaël

like image 33
Mickaël Andrieu Avatar answered Sep 23 '22 02:09

Mickaël Andrieu