Intellij and Node

Posted on Tuesday, April 14, 2015

As I start developing in node from scratch I want to do it right.  First thing I want to do is set up Intellij to work with node.

Install NodeJS Plugin

This assumes you have NodeJS installed on your system.  To check if it is installed you can run the following from command line.

  > node -v

I am using this page as my install guide [1]

Open up Intellij I am running version 14.1 Ultimate Edition.

From the File menu click on Settings.

Select Plugins, then click on Browse Repositories

Search for nodejs, and install the NodeJS plugin

Click Yes.

The download runs

Click Restat Intellij IDEA

For some reason it does not restart,  but that window does close.  Click Apply

Click Restart.

Configure the NodeJS plugin

From the File menu click on Settings

Under Languages & Frameworks Click on "Node.js and NPM"
Confirm that the Node Interpreter is correct and the correct version, if it's not set it up.

Configure the Core Modules

If I am reading this right you need to Configure the Core Modules for NodeJS if you want

·         code completion
·         reference resolution
·         validation
·         debugging

For NodeJS core modules (fs\, path, http, etc.)

So how do you set this up?

This is my second time installing nodejs and it looks like it remembers my configured module (In fact I tried to make it forget to no avail)

I installed Intellij on another machine to show you how to configure it.

Chances are you have this,  Source are not Configured.

Click Configure

I am going to let it download the modules.

Click Configure

The download starts.

Click Edit Usage Scope

I am not sure on this screen… I think it's OK,  click OK.

Create a new Node/Express Project

From the File Menu select New -> New Project.

Select Node.js and NPM and click Next.

Give it a name and click Finish.

Oh!  This popped up when the project was created.  Maybe it needs to be configured per project.

Click Configure

It downloads

OK, looks like I have a basic set up.

Run the program.

Looks like it started and is running on port 3000.

Nice it's working

Poking around

Code Completion

I opened app.js and tested out the code completion.  I added this to the top and low and behold node code completion.

npm, adding module

What is a simple way to add a module to a node project in Intellij?

First let me try the terminal.   (I am going to install the bootstrap module)

Did that work?

Looks like that worked just fine J

A gotcha!

After writing this I kept having issues when I created new Node Projects, I had lost my auto completion.

To really fix it I found this post showing how to fix this. [2]

To fix it do the following.

From the file menu select Settings.

From the Language & Frameworks select JavaScript then Libraries.

Click Download.

From the pull down select "TypeScript Community stubs".

Scroll down to node and click Download and Install.

After it downloads make sure it is enabled globally, click OK.

Now you get code Completion.


[1]        Intellij Help node.js
                Accessed 4/2015
[2]        NodeJS Auto Complete in IDEA
                Accessed 4/2015

1 comment: