Questions tagged [yargs]

Yargs is a node.js package that helps you build interactive command line tools, by parsing arguments and generating an elegant user interface. Use this tag for questions relating to the Yargs node.js library.

143 questions
0
votes
1 answer

yargs argument not binding correctly in linux

I am trying to run a node application which uses yargs to read arguments. Following is the code for that. export class RunCommand { public async run(): Promise { let commandMap: { [key: string]: any; } = {} …
S7H
  • 1,421
  • 1
  • 22
  • 37
0
votes
1 answer

Calling one command in Yargs calls other commands as well

I am learning nodejs and yargs and tried to implement it in my code using command function. I am trying to make a CLI based note taking app. I have two files app.js and utils.js, I run app.js and utils.js is imported in app.js to use functions in…
Piyush Keshari
  • 170
  • 2
  • 10
0
votes
1 answer

Getting function not defined for yargs.getHelp()

I am looking to get the automatically generated help that results from yargs.getHelp() and instead I am getting an error that the function is not defined. Here is the sample code: const yargs = require('yargs/yargs'); const { hideBin } =…
habadeer
  • 91
  • 6
0
votes
1 answer

How to set positional arguments via npm test script in package.json file?

I'm running AVA test now and I have 3 positional arguments that will be passed when running the command. For example: npm test But I wish to put the first 2 positional arguments inside packaga.json file so that I don't have to…
jialeee17
  • 601
  • 2
  • 7
  • 12
0
votes
1 answer

Writing unit test case for third party cli package

I have a basic CLI program built using yargs. I'm able to cover test cases for exported functions in the application. As you can see below test coverage is not done from line 12-18 which. How do we write unit test coverage for third-party package…
sravis
  • 3,562
  • 6
  • 36
  • 73
0
votes
1 answer

How do I make Yargs exit if it is passed an invalid flag?

I am using the Yargs JavaScript library for parsing command-line arguments. The following is a Hello-World-style Yargs program. By default, it includes "--help" and "--version", and I am adding a 3rd option, "--copy": const argv =…
James
  • 1,394
  • 2
  • 21
  • 31
0
votes
2 answers

Trying to setup a service built with YARGS using PM2

So, i have a script to define a service where I can use change streams on mongo. I made it with Yargs so i can pass all the arguments to the application. But when i try yo daemon it with pm2 I´m having hard time passing the command with all the args…
0
votes
1 answer

In this bash script, what does "-" mean? And how could one find out what it means?

Here's the script: node /app/ganache-core.docker.cli.js — quiet \ — account=”0x873c254263b17925b686f971d7724267710895f1585bb0533db8e693a2af32ff,100000000000000000000" \ —…
Zach_is_my_name
  • 59
  • 3
  • 14
0
votes
1 answer

yargs is throwing a ExperimentalWarning

I am writing a node.js CLI program and for some reason when I just include yargs like const yargs = require("yargs"); I get a warning: (node:30562) ExperimentalWarning: Conditional exports is an experimental feature. This feature could change at…
Jamie
  • 1,909
  • 3
  • 22
  • 47
0
votes
3 answers

Using yargs (npm package), how to give an error if command not found?

I have yargs with 2 commands? yargs .command('test-all','',handler) .command('test-file','',handler) .argv The user inputs: node myapp.js other-command But yargs don't throw an error. What should I do?
Aminadav Glickshtein
  • 23,232
  • 12
  • 77
  • 117
0
votes
2 answers

Fs operations with Yargs

I have to perform some operations with Yargs.For example- 1- Write in a file using fs module and for every write operation need to create a new file, 2-You must take i/p from user as fileName and keep saving fileNames in one array (array part is not…
sunny
  • 85
  • 1
  • 1
  • 6
0
votes
1 answer

I can not create a React project

I started learning React.js and when I type in the command line npx create-react-app {name of project} it starts downloading the dependencies but at the end I get an error with yargs-parser being a low level vulnerability, I've tried updating the…
Pier Gaub
  • 21
  • 5
0
votes
1 answer

npx create-react-app not showing latest bump to webpack-dev-server 3.11.0

This is my first SO question, so apologies for the lengthy amount of code. I'm trying to start a new project with create-react-app. I ran the following command: npx create-react-app jam-box --use-npm because I want to use npm instead of yarn, and…
0
votes
1 answer

Why terminal does not show other yargs command?

When i run command node app.js --help , terminal shows only add command meanwhile i have defined three commands and all of them works. And when i use parse() method instead of argv why i get 'Removing a note' printed 2 times ? const yargs =…
Sanket
  • 11
  • 4
0
votes
1 answer

difference between calling builder-function chained and calling it on a variable containing the builder in typescript

When using the builder provided by yargs with chained calls like the following example, everything works fine. const foo = yargs(stringArray) .string('bar') .describe({ 'bar': 'informative text', }).argv; But when trying to…
Nerethar
  • 1
  • 1
  • 1