question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

yargs.argv returns undefined

See original GitHub issue

The below code returns undefined import yargs from "yargs"; const command = yargs.argv._[0]; console.log(command);

$ node index.js help i have also tried yargs.argv.$0

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:6

github_iconTop GitHub Comments

5reactions
Sseroancommented, Mar 27, 2022

import yargs from “yargs”;

console.log(yargs.arg)

This returns undefined too. How did you resolve this?

This helped me …

import yargs from “yargs”;

console.log(yargs(process.argv).argv);

0reactions
AdleeAfifcommented, Nov 21, 2022

hello, may i know

import yargs from 'yargs'
import { hideBin } from 'yargs/helpers'

console.log(yargs(hideBin(process.argv)).argv)

This worked for me, same is mentioned in the yargs documentation.

May i know which documentation are you mentioning? I did some searching but failed to find it

This is the documentation I referred https://www.npmjs.com/package/yargs

Sorry for the reply but thanks😊

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why is .argv_[0] returning undefined when moving yargs ...
argv ;. and when I run the file, using list as the command, I receive the following error from the terminal: TypeError ...
Read more >
Additional documentation - yargs - JS.ORG
If key is an array, all elements will be parsed as numbers. If the option is given on the command line without a...
Read more >
How to use the yargs.argv function in yargs - Snyk
To help you get started, we've selected a few yargs.argv examples, based on popular ... return null; } const uo = url.parse(yargs.argv.server); const...
Read more >
yargs.Argv.argv JavaScript and Node.js code examples
lib/cli.js/undefined/argv. /** * Returns a parsed array of CLI arguments and options * * @since 3.0.0 * @alias lando.cli.argv * @return {Object} Yarg...
Read more >
yargs-command-env 0.0.0 | Documentation
If options.defaults is undefined, the object argv.env will be used before ... Yargs Command Module with the following properties ( out is the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found