WebStorm - 未解析的变量或类型 - Sails/module.export [英] WebStorm - Unresolved variable or type - Sails / module.export

查看:97
本文介绍了WebStorm - 未解析的变量或类型 - Sails/module.export的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试修复 JavaScript 中的 WebStorm v11.0.4 警告.SailsJS 应用程序中自定义类型的许多 unresolved variable or type 错误,例如这个:

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:

我已经在 WebStorm 中启用了 Node.js.另外,不知道它是否已链接,但无法将Node Globals"视为要启用的库(见下图).

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

现在,我显然不是 JavaScript 专家.在 ./api/services/DataService.js 文件夹中有一个名为 DataService.js 的文件,但即使在那里,也会发生完全相同的错误,并且 DataService 类型似乎没有定义:/

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 :/

任何想法,是否有一种干净的方法来摆脱这些警告(理想情况下让 WebStorm 意识到这些类型),或者我是否只需要忽略它们并接受它?这是在 Sails 或其他地方定义的全局类型吗?

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?

编辑:一种有效的解决方案是this问题.但我的 JS 不够好,无法理解此解决方案的影响.

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.

谢谢!

推荐答案

似乎您需要启用 Node Core 库(正如 lena 也评论过的),
在 WebStorm 中:

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

  1. 转到文件 -> 设置 -> 语言和;框架 -> Node.js 和 NPM
  2. 按下启用"按钮,确保Node.js 核心库已启用".
  3. 单击确定"保存设置.

注意:请确保您在设置"中进行操作,而不仅仅是在默认设置"中进行

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

这篇关于WebStorm - 未解析的变量或类型 - Sails/module.export的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆