what's the best way to test coffeescript code with webstorm ?

Is there any other way than the console, to quicly test coffeescript code, like quickly printing result of a console log statement or such ?
How do you guys do ?



I can suggest using node.js for this (if you do have node.js installed):
- create a Node.js run configuration
- specify your .coffee file as a javascript file to run
- turn 'run with coffeescript plugin' on, set a path to coffee executable

or, even better (to avoid creating run configurations for each file, etc.):

- create a new external too (Settings/External tools)
- specify a path to node.exe as a program
- add  'path_to_coffee_executable $FileName$' as parameters (like C:\Users\Elena.Pogorelova\AppData\Roaming\npm\node_modules\coffee-script\bin\coffee $FileName$)
- set a working directory to $FileDir$
then you will be able to run this tool from a right-click menu of your file


Thanks for your answer.
I'm setting this up.

As for the 'options' checkboxes, should I check "synchronize files after execution", "Open console..." ?

I'm not sure how this is supposed to work, when I run it I get

"/usr/local/bin/node /usr/local/bin/coffee WordscountCOFFEE.coffee

Process finished with exit code 0"


You can keep the default settings for options.
Do you have any console.log calls, etc. in your code? Evaluating using the coffeescript plugin is not supposed to execute your code in browser, etc. - all you will see are console messages


Thanks, works fine.
Only problem is while I type, at some point the coffee code is not valid, the new window I created is violently replaced by the coffee error window, I have no way back to my window other than right click and launch it again.
Anyway to prevent coffee from checking code, or better, have it in another window tab?

here is an example of error message I get:

/usr/local/bin/coffee --map --bare --compile Console.coffee
Console.coffee:2:68: error: unexpected CALL_END
console.log my + 6 + 4 + 6 + 5 + 6 + 6 + 5 + 6 + 6 + 6 + 7 + 5 + 5 +


disabling the immediate compile in the file watcher seems to resolve this, is this correct fix ?


Hi Elena,
how can I do the same with Javascript; creating external tool to run js code,  as I did with coffee ?
(I'm on a mac environement and have nodejs installed)



a tool would be very similar:
- create a new external too (Settings/External tools)
- specify a path to node as a program
-  add  $FileName$ as parameters
- set a working directory to $FileDir$
- make sure to check Show in/Project views and Editor menu to be able to run your tool from file right-click menu in Project view/Editor

then you'll be able to run your tool from a right-click menu of your .js file - the file will be passed to node as an argument


Please sign in to leave a comment.