Webstorm 8.0.5, 9, and 9.0.1 Issue regarding "Unresolved method or function"

I'm rather new to Webstorm (and am enjoying it quite well, so far).  During my explorations, I've setup a vanilla Node.js/Express/EJS project, to which I've made no code changes...so, my question refers to the code generated automatically by Webstorm for a Node.js/Express/EJS project.

The issue I'm facing, is that in the project file app.js, Webstorm has identified "urlencoded()" in the following line of code as an unresolved method or function:

  app.use(bodyParser.urlencoded({ extended: false }));

I've been careful to include the following external libraries in the vanilla project:

* body-parser-DefinitelyTyped
* express-DefinitelyTyped
* Node.js v0.10.32 Core Modules

When I right click in the code area for app.js, I can select "Use JavaScript Library" to see that, indeed, my external libraries are selected.

My questions:

1)  What would cause Webstorm to identify urlencoded() as unresolved?

2)  How do I fix this?

For convenience, I've attached a screenshot, as well.

Thanks in advance for any help/insights!



Attachment(s):
ScreenShot.tiff
10 comments
Comment actions Permalink

Can't recreate - the method is resolved to 'exports.urlencoded' in node_modules\body-parser\index.js:9 - see attached screenshot
Can you check if the problem persists after invalidating caches?



Attachment(s):
express.png
0
Comment actions Permalink

Thanks for your response!

Unfortunately, selecting "Invalidate Caches / Restart" does not appear to help the situation.

I would note that your attempt to recreate what I'm seeing isn't quite right:  from your screenshot, it appears that you have chosen a Node/Express/Jade project, whereas I have a Node/Express/EJS project.  Could this difference be important?

0
Comment actions Permalink

It makes no difference - I get the same results when using EJS instead of Jade


0
Comment actions Permalink

Well, this is certainly odd!

If I create a new project (with Jade, this time) I get the same results as before:  an unresolved method for urlencoded().

Moreover...if I dig into node_modules --> body-parser --> index.js I see that the line

  var _urlencoded = exports.urlencoded(opts);

also indicates that urlencoded() is unresolved.

Any further suggestions?

0
Comment actions Permalink

This problem continues for me with version 9 of Webstorm.  For the heck of it, when I upgraded to WebStorm 9, I attempted a complete uninstall/re-install; however, the "Unresolved method or function" issue has remained.  Also, I'm noticing that it's not just the urlencoded() method that is troublesome.  When I right-click on the json() method in the following line of code (here, the json() method is NOT highlighted by WebStorm as undefined)

  app.use(bodyParser.json());


and use WebStorm's "Go To --> Declaration" feature, I'm prompted with three choices, none of which is from the body-parser module.  Instead, the modules listed include:  express-->lib-->responses.js, ejs-->ejs.js, and ejs-->lib-->filters.js).

Not sure that it would make any difference, but all the Node packages involved are at their latest versions, as is Node.js (version 0.10.32).

For now, I've had to disable the "Unresolved JavaScript function" option found under Preferences-->Editor-->Inspections-->JavaScript-->General.  Rather a bummer!

Any suggestions for a fix are appreciated!

0
Comment actions Permalink

Recreated - this works fine with Express4.2.0 + body-parser 1.0.0, but fails with 4.9.0 + 1.8.1

0
Comment actions Permalink

Ah---very interesting!  I'll have to confirm this on my side as soon as I get the chance.

In the mean time, is the problem then with the newer versions of the Express and body-parser libraries?  Or is there some issue with the way WebStorm processes these libraries to find method definitions?

If the issue is with the newer versions of the libraries, what manner of trouble are we talking about, here?  E.g., is there something significantly wrong with the libraries in question?

0
Comment actions Permalink

Any thoughts from the Community on this?

I continue to see this behavior with WebStorm 9.0.1, too.  I'd prefer not having to downgrade the Express and body-parser libraries to compensate.

0
Comment actions Permalink

the way body-parser methods are defined has changed, and webstorm is not able to understand them anymore. The issue is logged as https://youtrack.jetbrains.com/issue/WEB-14072, please vote

0
Comment actions Permalink

Okay; thanks for your help!

0

Please sign in to leave a comment.