How to fix WebStorm not recognizing some Node.js Express properties?

≡放荡痞女 提交于 2019-12-03 05:41:50

问题


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());

How to fix that?

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

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


回答1:


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 = {};

Otherwise, WebStorm cannot understand that you have dynamic properties.

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



来源:https://stackoverflow.com/questions/15467921/how-to-fix-webstorm-not-recognizing-some-node-js-express-properties

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