如何解决WebStorm不识别某些Node.js Express属性? [英] How to fix WebStorm not recognizing some Node.js Express properties?

查看:693
本文介绍了如何解决WebStorm不识别某些Node.js Express属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

执行 express mysite 和npm install -d之后,我用WebStorm打开了生成的目录,IDE不能识别以下Express方法: p>

After execute express mysite and ``npm install -d` I opened the generated directory with WebStorm, the following Express methods aren't recognized by the IDE:

app.use(express.favicon());
app.use(express.logger('dev'));
app.use(express.bodyParser());
app.use(express.methodOverride());

如何解决?

注意:IDE在我做了这个,并在设置中将模块目录添加为JavaScript库,但仍然无法识别上述方法。看到图片看到IDE到目前为止所认可的

Note: The IDE was capable to recognize lot of new things after I did this and add module directory as JavaScript Library in the settings, but still not recognize the above mentioned methods. See the image to see what the IDE recognized so far

在下面的图片中,您可以看到IDE仍然无法识别:

In this following image you can see what the IDE still not recognize:

推荐答案

这适用于几乎任何JS项目。您应该明确定义一个对象的属性写JSDocs:

This applies to almostly any JS project out there. You should explicitly define an object's properties or write JSDocs:

/**
 * @memberOf   myLib
 * or
 * @name       myLib.MyDynamicallyLoadedModule
 */
var MyDynamicallyLoadedModule = {};

否则,WebStorm无法理解您有动态属性。

Otherwise, WebStorm cannot understand that you have dynamic properties.

(是的,我知道你是指Express,但这是WebStorm的工作原理)

(yeah, I know you're refering to Express, but that's how WebStorm works)

这篇关于如何解决WebStorm不识别某些Node.js Express属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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