Search code examples
javascriptnode.jswebstormcode-completion

Yargs.argv unresolved variable in WebStorm


enter image description here

I'm new to NodeJS, I've installed yargs already but it argv can not be recognized. Any idea why?!


Solution

  • The properties are created dynamically, that's why WebStorm is not able to resolve them during static code analysis.

    To work out the issue, you need installing yargs typings (@types/yargs): hit Alt+Enter on "yargs" in require("yargs"), choose Install Typescript definitions for better type information:

    enter image description here

    See https://www.jetbrains.com/help/webstorm/configuring-javascript-libraries.html#ws_jsconfigure_libraries_ts_definition_files

    This should help:

    enter image description here