0

I just started a new NodeJS application in PhpStorm which uses some external packages. Unfortunately I see a lot of Unresolved variable or Unresolved function or method warnings:

enter image description here

Obviously this is very distracting. Can I somehow manually tell the IDE to load some definition files of the external packages I use (e.g. mongoose in this example)?

If I find no other solution I'd simply disable those inspections which is kind of a bad "fallback" since they usually provide some good hints for typos etc.


Solution:
I had 2 different node_modules directories in my project:

project\client\node_modules\...
project\server\node_modules\...

Both were marked as excluded. I simply removed the excluded mark (right-click on the folder in the project tree). PhpStorm shows correct auto completion now and the Unresolved warnings are gone.

0

1 Answer 1

2

If you have jetbrains suite, It's better to use webstorm for nodejs application.

However, if you want to keep phpstorm. You can use a jshint module for global variables declaration, and use jsdoc for variable instance :

/**
 * Description
 * @type {Schema}
 * @property {object} methods
 */
var Schema;

-- EDIT --

Have you set up your phpstorm as the jetbrains doc ? Work on nodejs with phpstorm

Sign up to request clarification or add additional context in comments.

5 Comments

Yes, I'd like to stay with PhpStorm. Writing the jsdoc myself is not really an option since that would be a huge task. The ~ 30 lines of code in the screenshot above already have 7 unresolved vars & methods which would need manual handling...
FYI: PhpStorm = WebStorm + PHP + Database/SQL
@LazyOne Sorry, that's not true anymore, WebStorm has different release cycle than PhpStorm, it can have new JS/CSS/HTML oriented features faster than PhpStorm, PHPStorm doesn't support JS part like Webstorm. Webstorm has a direct npm module scanner which is the solution of the issue here.
@ThomasLeduc Oh please... jetbrains.com/phpstorm " PhpStorm = WebStorm + PHP + DB/SQL All the features of WebStorm are included into PhpStorm, and full-fledged support for PHP and Databases/SQL support are added on top."
Please see the edit, specially this : jetbrains.com/help/phpstorm/2016.2/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.