问题
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:
- Go to File -> Settings -> Languages & Frameworks -> Node.js and NPM
- Make sure that 'Node.js Core library is enabled' by pressing Enable button.
- 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