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.
Questions tagged [yargs]
143 questions
0
votes
2 answers
React app, cannot find library, which I have installed manually
I am building a React app. I installed yargs and argsert manually by npm. For some reason, when I start the development server, I get the following error and stack trace. The two modules in question are listed clearly as argsert and yargs. I am…

anon says hello
- 133
- 1
- 2
- 10
0
votes
1 answer
TypeError: notesExist.push is not a function?
i'm just newbie on nodeJs ,and i need your help
my utile.js file :
const fs = require('fs');
const addNotes = function(name,age,birthday){
const notesExist = loadNotes()
notesExist.push({
name: name,
age:…

Simon
- 39
- 7
0
votes
0 answers
Any module is support npx like argv parser?
Any module is support npx like argv parser?
i write a module ynpx
https://github.com/bluelovers/ws-ypx/tree/master/packages/ypx
but i can't found a safe way make input cli argv parse like npx do
ynpx -p xxx yyy -p
what i expected is
all argv befroe…

bluelovers
- 1,035
- 2
- 10
- 22
0
votes
1 answer
Use yargs with Typescript
I don't understand when I abstract options to a variable (or even import from another file), Typescript complains with:
Argument of type '{ exclude: { type: string; required: boolean; description: string; default: never[]; alias: string; };…

cusejuice
- 10,285
- 26
- 90
- 145
0
votes
1 answer
The contents in text file will be filenames, how to take and compare with new filename(whether they are matching or not)
Here I am putting the file names in to filename.txt, but I am not getting how to compare with existing file in the filename.txt
const yargs = require('yargs')
const fs = require('fs')
const command = process.argv[2]; // I am giving in terminal like…

Jeevith_2893
- 1
- 3
0
votes
1 answer
terminal `node ./src/index.ts` SyntaxError
this my code
import * as yargs from 'yargs';
const newYargs = yargs.argv;
console.log(newYargs.value);
run the command in the terminal node ./src/index.ts i get this error
import * as yargs from 'yargs': SyntaxError: Cannot use import statement…

Edgar
- 6,022
- 8
- 33
- 66
0
votes
2 answers
SyntaxError: /Users/3x7r3m157/Development/Javascript/db.json: Unexpected end of JSON input
In this bug I just cant seem to find, I'm reading from a .json file called db.json updating the json and trying to write to the .json file. Although I'm parsing and stringifying the json, I'm getting this error:
SyntaxError:…

Austin Atendido
- 35
- 2
- 9
0
votes
1 answer
pushing into string not a function
I have a simple problem that's confusing the hell out of me. I tried looking for other similar problems solved but couldn't find this exact problem. I am trying to push a string into an empty string and I'm getting an error is thrown that says the…

Austin Atendido
- 35
- 2
- 9
0
votes
1 answer
getting message for "Invalid values:" for yargs
I am using yargs to develop a cli tool . Here is simple yargs code to process the cli option
let argv = require('yargs')
.usage('$0 [option]')
.command(
'validate_zip',
'validate the directory structure for the zip…

made_in_india
- 2,109
- 5
- 40
- 63
0
votes
1 answer
yargs warning: Too many arguments provided. Expected max 1 but received 2
I have an issue with my yargs configuration:
const argv = require('yargs')
.boolean('reset', {
alias: 'rs'
})
.boolean('refreshConfig', {
alias: 'rc'
})
.option('harvest', {
alias: 'h'
})
…

Vivien Adnot
- 1,157
- 3
- 14
- 30
0
votes
1 answer
Proxyquire : Proxy-require yargs and pass values to it
I have a code as below src/example.js:
var argv = require('yargs')
.usage('service 1.\nUsage: $0 -s [host] -n [port]')
.alias('s', 'host')
.alias('n', 'port')
.describe('host', 'Hostname to be used')
.describe('port', 'Port on which service will…

user1452759
- 8,810
- 15
- 42
- 58
0
votes
1 answer
Passing arguments to Node.js program
I'm trying to pass 2 mandatory arguments for a Node.js program I'm creating.
I'm using Yargs to do it like this:
const yarg = require("yargs")
.usage("hi")
.options("m", {demandOption: true})
.options("m2", {demandOption: true})
.argv;
This works…

CodeMonkey
- 11,196
- 30
- 112
- 203
0
votes
0 answers
yargs (node module): command module files... parse the command, but without automatically executing the command's exports.handler code
I'm using yargs with command modules, i.e. separate file for each command, with each command file defining exports.command, exports.desc, exports.handler for its own command.
For 60% of my commands, the way it works by default is fine. But the…

LaVache
- 2,372
- 3
- 24
- 38
0
votes
2 answers
Yargs.argv is always [object Object]
Ubuntu 16.04. I'm doing a node.js course on Udemy. I tried it with the exact version the instructor was using, then I upgraded to the latest(11.0.0). Both gave the same output.
const yargs = require('yargs');
var argv =…

Niall Quinlan
- 38
- 4
0
votes
0 answers
How do I specify an option can be both a number or string?
I am trying to set up an option that is both type: "number" and type: "string".
The documentation for .option() specifies that the type property of the option options object should be a string, and two of those choices are number and string.…

bb216b3acfd8f72cbc8f899d4d6963
- 743
- 11
- 21