Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WebStorm - Unresolved variable or type - Sails / module.export [duplicate]

Trying to fix WebStorm v11.0.4 warnings in JavaScript. Lots of unresolved variable or type errors for custom types in SailsJS application, such as this one:

unresolvedVariable01

I already enabled Node.js in WebStorm. Also, don't know if it is linked, but cannot see "Node Globals" as a library to enable (see pictures below).

unresolvedVariable02

unresolvedVariable03

Now, I'm clearly not a JavaScript pro. There is a file called DataService.js in the ./api/services/DataService.js folder, but even in there, the exact same error occur, and the DataService type appears to be defined nowhere :/

Any idea, if there is a clean way to get rid of those warnings (ideally making WebStorm aware of those types) or if I just need to ignore them and live with it? Is this a global type defined in Sails or somewhere else?

Edit: One solution that works is in the comments of this question. But I'm not good enough in JS to understand the impact of this solution.

Thanks!

like image 990
evilmandarine Avatar asked Aug 09 '16 14:08

evilmandarine


1 Answers

Seems you need to enable Node Core library (as lena also commented),
Within WebStorm:

  1. Go to File -> Settings -> Languages & Frameworks -> Node.js and NPM
  2. Make sure that 'Node.js Core library is enabled' by pressing Enable button.
  3. Click OK for saving settings.

NOTE: Make sure you do it within 'Settings' and not only in 'Default Settings'

like image 182
Mercury Avatar answered Nov 07 '22 02:11

Mercury