Attaching the Sources of Node.js Core Modules

Sergey Simonchik

When developing a Node.js application it can be convenient to have code completion, validation and debugging capabilities for Node core modules (fs, path, http, etc).

Unfortunately, these modules are compiled into the binary. So you have to download the Node.js source code and attach it to the project (all the required sources are located in the lib/ folder). But every time you decide to upgrade your Node installation, you have to repeat these steps – and don’t forget to detach previously attached sources to avoid confusion in code completion and navigation!

Well, from now on there’s an easier way to attach the Node.js sources to your project.

1) Open the Node.js settings dialog by clicking this icon on the toolbar:

Alternatively, you can open the Settings dialog (File | Settings or IntelliJ IDEA | Preferences) and select JavaScript | Node.js.

2) Specify the path to Node.js interpreter and the Node.js version will be determined automatically.

3) Click Configure and the following dialog opens:

4) Click the ‘Download and Configure’ button to download Node.js sources to the IntelliJ system local folder. A JavaScript library named “Node.js 0.6.12 Core Library” will be created from the extracted source files of core modules.

Now, to make it work the right way, define a usage scope for JavaScript library just created. By default the whole project will be added to the usage scope. You can tune the usage scope by clicking the ‘Edit usage scope’ hyperlink:

OK, now let’s try to code-complete methods from http core module:

Our work is done here.

Attaching the sources of Node core modules from the editor

An alternative way to attach these sources to the project is to invoke a quick-fix:


Develop your Node.js applications with pleasure!

Download WebStorm for your platform from this project EAP page.

Note: Users of PhpStorm or other JetBrains IDEs – IntelliJ IDEA, PyCharm, RubyMine, and AppCode – should install the ‘NodeJS’ plugin from the plugin repository.

Comments below can no longer be edited.

12 Responses to Attaching the Sources of Node.js Core Modules

  1. Gijs says:

    March 27, 2012

    When will the PHPStorm plugin be updated? The current NodeJS plugin (0.2.2) is from the beginning of march and doesn’t seem to provide the feature described here.

    • Sergey Simonchik says:

      March 27, 2012

      Really soon. Please wait.

  2. Rapid0s says:

    March 28, 2012

    Nice 🙂 Is there any way to exclude TODOs when including node.js source ?
    This update certainly solves the above problem 🙂

    • Sergey Simonchik says:

      March 28, 2012

      Attaching the sources as it was described above shouldn’t add any TODOs from Node core modules.
      The old way of attaching sources was based on adding a new Content Root to the project. Unfortunately it’s impossible to exclude TODOs from files under project’s content roots.
      Vote for if you would like to specify a scope for TODOs.

  3. Ben J Clayton says:

    April 17, 2012

    This is great – I can confirm that it works exactly as described on PhpStorm 4.0 117.222 and plugin version 0.2.2.

    Is there any way to attach the documentation? (CMD-J) When I type a function the parameter popup shows me the parameters (which is dead useful) if there was any way of attaching the documentation as well I wouldn’t need to go to the node site at all..

  4. ty says:

    May 10, 2012

    My network is very slow,and the download always time out,so,how can i use the nodejs?

    • Sergey Simonchik says:

      May 10, 2012

      Increased timeout will be available in the next release.
      Also it will be possible to select locally downloaded Node.js sources archive file (*.tar.gz) and avoid network communication.

      • ericwangqing says:

        May 12, 2012

        Is there anyway to use a downloaded archive now? I find a file named ‘nodejs-v.0.6.17-src.tar.gz’ under the system/extLibs/ folder. But when I rename the downloaded ‘node-v0.6.17.tar.gz’ as it, WS didn’t pick it up.

        • Sergey Simonchik says:

          May 12, 2012

          You don’t need to do anything with downloaded ‘nodejs-v.0.6.17-src.tar.gz’. WebStorm (actually NodeJS plugin) extracts lib/ folder from it, creates a JavaScript Library from the extracted core modules and attaches the library to the project. And after this you gain code completion for core modules.
          If you encounter any problems feel free to file an issue in the (select ‘Node.js’ as a subsystem).

  5. Martin Cleaver says:

    June 22, 2012

    You might as well make the IDE pop-up that shows this message actually link to the option in Configure to test it.

    That would have saved me some Googling…

    • Sergey Simonchik says:

      June 23, 2012

      You can invoke a quick-fix on error highlighting (see the last screenshot).

      Quick-fix popup will be shown automatically in WebStorm 5.0.