"module" undefined - Node

this is driving me absolutely crazy.  I've setup node and all that in preferences.  But I'm still having JSHint and JSLint bitch about node syntax in my code files...yet when I run the code it's fine!  I don't like that the intellisense is bitching here and I cannot figure out how to make it happy

Screen Shot 2015-03-17 at 9.08.32 PM.png

3 comments
Comment actions Permalink

The error comes from JSHint/JSLint (not sure why you need both linters  enabled at the same time - they do not differ that much, your will just  get 2 identical errors instead of one for each issue).
To avoid such errors, you have to configure JSHint/Lint accordingly.   They both work on per-file basis and don't 'see' global variables  defined in other files unless they are added to 'global' list. This can  be done by either adding the corresponding comments (/* global module*/  to your code - see http://www.jshint.com/docs/),  or by adding variables/functions you'd like to use globally to the  'Predefined' list in Preferences -> Languages & Frameworks ->  Javascript -> Code Quality Tool -> JSHint -> Predefined  (,separated). It's the last item in the list of JSHint options. Same for  JSLint: Preferences -> Languages & Frameworks -> Javascript  -> Code Quality Tool -> JSLint -> Predefined (,separated)

0
Comment actions Permalink

Thanks, what do you mean adding functions in the predefined, can you give an example?

Also, I did not know if you install stuff via npm that Webstorm just picks it up automatically?  I thought you still have to go in manually in preferences at various places to make sure it's 100% recognized in webstorm as far as intellisense.  For example I found even after installing express.js I had to go into Webstorm and install express for my project.  Maybe I didn't install npm express globally?  So if you install stuff globally does that disable the requirement to further have to go into Webstorm preferences for that module and tweak settings?

0
Comment actions Permalink
Thanks, what do you mean adding functions in the predefined, can you give an example?

Just add a name there - see attached screenshot

I thought you still have to go in manually in preferences at various places to make sure it's 100% recognized in webstorm as far as intellisense


Normally you shouldn't - it's enough to have the corresponding module installed locally. But in some cases (when the Node.js modules are generated dynamically, for  example), resolving them during static analysis is next to impossible (Express module is a good  example). We usually suggest using TypeScript stubs as a workaround - see http://youtrack.jetbrains.com/issue/WEB-6667#comment=27-589563



Attachment(s):
predef.png
0

Please sign in to leave a comment.