Search code examples
node.jsyargs

require yargs package - NodeJS


What is the differences of var argv = require("yargs") and var argv = require("yargs").argv? Into variable argv how the same time that i require a package, there are all functions/modules of package but .argv what is it?

Thanks all Morris


Solution

  • require('yargs') loads the yargs module whih will immediately parse command line options for you. .argv will contain the options and values the user passes. You could also write it as :

    const yargs = require ('yargs')
    const argv = yargs.argv