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

你离开我真会死。 提交于 2021-02-18 06:03:48

问题


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:

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).

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!


回答1:


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'



来源:https://stackoverflow.com/questions/38853027/webstorm-unresolved-variable-or-type-sails-module-export

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!