I\'m using WebStorm as the IDE.
Here\'s my folder structure and express.js insalled:
Make sure that you have a package.json file in the root of your website.
In Webstorm, there are three places in your settings (ctrl-alt-s
) where you can update settings for Node.js projects.
Settings: Javascript Libraries
First, in Javascript | Libraries
you can specify that Node libraries should be loaded. Your set of libraries may look different than this, but it should be pretty close...or, if needed, you can add the libraries so that your flavor (node, io, whatever) shows up.
JSHint
Second, if you have JSHint enabled, you should also enable the Node.js environment so that JSHint acts appropriately.
Nodejs and NPM Settings
You can (should) also set the path to your node executable. Webstorm will also detect your globally installed modules, too, and show you if your versions are up-to-date.
The Official Docs
Finally, this reference link contains much more information about WebStorm and Node: JetBrains Webstorm -- Nodejs Docs
Under Preferences > Languages & Frameworks > Node.js and NPM, make sure "Node.js Core library is enabled" is enabled.
Under Settings > Languages & Frameworks > Node.js and NPM
make sure to check Index internal node modules
. After it's done indexing, it will recognize the require keyword.
On the new Webstorm versions, just going above error and clicking in More Actions...
(or ALT+ENTER) and selecting
Enable Node.js coding assistance will solve this.
To solve these problems on the new Webstorm versions, you need to enable the Coding assistance for Node.js.
To do this, go on the Settings
> Languages & Frameworks
> Node.js and NPM
and click on the Coding assistance for Node.js
option, and then click OK to save:
This will solve all Node.js unresolved variables and functions.