Codepath

Editors: WebStorm & IntelliJ

Setting up WebStorm or IntelliJ for use with node.js

Following the below steps will give you the following features:

  1. Code completion recommendations
  2. Run from editor
  3. In-editor step debugging a la node-inspector

Note: Please remember, since JavaScript is a dynamic language, the code completion is typically over generous, and there are no guarantees that those properties or methods actually exist. Turning off Preferences > Languages & Frameworks > JavaScript > Weaker type guess for completions to limit the suggestions.

Steps:

  1. Preferences > Languages & Frameworks > JavaScript:
    1. JavaScript language version => ECMAScript 6
    2. Prefer Strict mode => checked
  2. Copy your node path to the clipboard

    $ which node | pbcopy # copy path into clipboard
  3. Preferences > Languages & Frameworks > Node.js and NPM

    1. Node interpreter => [paste path from previous step]
    2. Sources of Node.js Core Modules => https://nodejs.org/dist/v4.0.0/node-v4.0.0.tar.gz (match to your installed version)
  4. Click Apply at the bottom of the current Preferences window

  5. In Preferences > Languages & Frameworks > JavaScript > Libraries, enable the following:

    • Node.js v4.0.0 Core Modules
    • ECMAScript 6
    • Node.js Globals
  6. Click Okay at the bottom of the current Preferences window

  7. Run > Edit Configurations... > Defaults > Node.js

    1. Node interpreter: => Same "Node interpreter" value from above (which node | pbcopy)
    2. Node parameters: => --harmony --use-strict
    3. Working directory: => Project root
    4. JavaScript file: => index.js or your main project file

Now you can freely add breakpoints in the gutter (the space just to the left of your code) and debug with Run > Debug (^D)! Super exciting!

Fork me on GitHub