Webstorm Not exposing Node NPM methods
Details:
WebStorm 2017.2.5
Build #WS-172.4343.25, built on October 20, 2017
Licensed to - intentionally deleted
Subscription is active until November 30, 2017
JRE: 1.8.0_152-release-915-b12 x86_64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Mac OS X 10.12.6
Specific Problem:
WebStorm when loaded with NPM modules and Node & NPM is "enabled" usually exposes the methods in the NPM module, making it easy to use dot.notation when accessing these methods.
However, in a recent project I am using Redis NPM module (https://www.npmjs.com/package/redis) which is a fairly well known module. This contains almost all if not all of the Redis calls. However, when I include these methods in a dot notation syntax (obviously after a require), such as:
redis.hgetall.etc etc
WebStorm will tell me "unresolved function or method" on the hgetall(). It also (obviously) will not find this method automatically as one types.
This does not only apply to "hgetall". It seems to actually apply to any method within the Redis module. WebStorm simply is not aware of them. The code though does work.
I do not know if this is also a problem with other NPM modules in WebStorm, but usually I have had access to all the methods within a module.
Before you ask
1. I know that to enable NPM modules they must be enabled in Pref and Enable.
2. I am using other NPM modules and have had no problems accessing the methods.
3. The directories the code points to in Node are correct (as proof I have access to all the other methods in the modules I am using)
Is there some step I am doing wrong or something I may have skipped, or some toggle I do not yet know about. This is not a critical bug but it certainly is annoying and forces double checking of every call made to Redis.
Any and all help would be appreciated
Please sign in to leave a comment.
Please provide a code snippet that can be used to recreate the issue
I apologize it took so long for a code snippet. To make matters really really clear I just took the code which works from the NPM Redis module site.
WebStorm does not expose half of these methods if not more. HGETALL which is a critical Redis method, and it does exist in the module gets marked as unresolved function or method. So does hset below. There is really no need for special code. Dump below into WebStorm, install Redis from NPM and you will see the methods are not exposed.
Thank you in advance for any help you can offer on the matter
var redis = require("redis"),
the problem is that hgetall(), as well as many other redis commands, is not defined statically anywhere in the code, that's why it's not possible to resolve it during static code analysis. As a workaround, please try installing redis TypeScript stubs (npm i @types/redis) - this should solve the issue: