On this page:

Introduction

CoffeeScript code is not processed by browsers that work with JavaScript code. Therefore to be executed, CoffeeScript code has to be translated into JavaScript. This operation is referred to as transpilation and the tools that perform it are called transpilers.

For more details about transpilation in IntelliJ IDEA, see the section Using File Watchers.

In either case, running CoffeeScript is supported only in the local mode. This means that IntelliJ IDEA itself starts the Node.js engine and the target application according to a run configuration and gets full control over the session.

For more details about running Node.js applications, see Running and Debugging Node.Js.

There are two approaches to running CoffeeScript in IntelliJ IDEA:

  • Transpile the CoffeeScript code manually and then run the output JavaScript code as if it were a Node.js application.
  • Run the original CoffeeScript code through the NodeJS run configuration and have IntelliJ IDEA transpile it on the fly.

Transpiling CoffeeScript manually and running the generated JavaScript code

  1. Transpile the CoffeeScript code into Javascript.
  2. Start creating a Node.js run configuration with the following mandatory settings:
    1. The Node.js engine to use. By default, the field shows the path to the interpreter specified on the Node.js page during Node.js configuration.
    2. In the Working directory field, specify the location of the files referenced from the starting CoffeeScript file to run, for example, includes. If this file does not reference any other files, just leave the field empty.
    3. In the Path to Node App JS File text box, specify the full path to the JavaScript file that was generated from the original CoffeeScript file during the transpilation.
  3. Save the configuration and click run.png on the toolbar.
  4. Proceed as while running a Node.js application.

Transpile CoffeeScript on the fly during run

  1. This mode requires that the register.js file, which is a part of the coffee-script package, should be located under the project root. Therefore you need to install the coffee-script package on the Node.Js page locally, as described in Installing and Removing External Software Using Node Package Manager.
  2. Start creating a Node.js run configuration as described in Running and Debugging Node.Js and specify the following mandatory settings:
    1. The Node interpreter to use. Select the relevant interpreter configuration or create a new one, see By default, the field shows the path to the interpreter specified on the Node.js page during Node.js configuration.

      For Linux and OS X, this setting is overridden by the Node.js from the path to the CoffeeScript transpiler executable file.

    2. In the Node parameters text box, type the following:
      --require coffee-script/register
    3. In the Working directory field, specify the location of the files referenced from the starting CoffeeScript file to run, for example, includes. If this file does not reference any other files, just leave the field empty.
    4. In the JavaScript file text box, specify the full path to the CoffeeScript file to run.
  3. Save the configuration and click run.png on the toolbar.
  4. Proceed as while running a Node.js application.