Issues when coding node.js using IntelliJ IDEA “Unresolved function or method”

I’m currently having a lot of fun experimenting with node.js using IntelliJ IDEA. I installed the node.js plugin, and although this added options to create a new ‘Boilerplate’ or ‘Express’ project, the rest of the node.js integration wasn’t quite so obvious…

In particular after creating a blank project and adding a few js files I noticed that several of the core node.js modules, such as ‘require’ were not being recognised by the IDE. I restarted the IDE and it did detect that I was coding using node.js, but it still didn’t detect these code modules e.g. “Unresolved function or method require” or “Unresolved function or method http”

It turns out that the IDE JavaScript libraries have to be configured properly. This can be done as follows (I’m using OSX, and so some of the menu names may be slightly different if you’re coding on Linux and Windows)

IntelliJ IDEA -> Preferences -> JavaScript -> Libraries 
-> [Ensure 'Node.js Globals' is checked]

This sorted the problem for me!

If you are interested you can follow my current experiment with node.js (using the excellent ‘Node.js In Action‘) in the following GitHub repo: https://github.com/daniel-bryant-uk/node-chat-experiment

1 comment
  1. James Black said:

    Cool thanks! 🙂

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: