Skip to content

onFinishCommand is not a function #1947

@stcn89

Description

@stcn89

code :

yargs(hideBin(process.argv))
  .parserConfiguration({
    'unknown-options-as-args': true,
  })
  .command(commands)
  .demandCommand(1)
  .completion('completion')
  .strict()
  .help()
  .wrap(120)
  .middleware(middleware)
  .fail((msg: string, err: Error, yargs: Argv) => {
    yargs.showHelp();
  })
  .onFinishCommand((success) => {
    console.log(success);
  })
  .scriptName('kit')
  .showHelpOnFail(true, 'Sorry, we could not figure out what you want.')
  .version('2.0')
  .epilogue('Epilogue test').argv;

If I remove the onFinishCommand call, it works just fine.
Here is the full error message :

/home/mypc/projects/my-first-yargs-project/src/index.ts:44
  .onFinishCommand((success) => {
   ^
TypeError: yargs_1.default(...).parserConfiguration(...).command(...).demandCommand(...).completion(...).strict(...).help(...).wrap(...).middleware(...).fail(...).onFinishCommand is not a function
    at Object.<anonymous> (/home/mypc/projects/my-first-yargs-project/src/index.ts:44:4)
    at Module._compile (internal/modules/cjs/loader.js:999:30)
    at Module.m._compile (/home/mypc/projects/my-first-yargs-project/node_modules/ts-node/src/index.ts:1056:23)
    at Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
    at Object.require.extensions.<computed> [as .ts] (/home/mypc/projects/my-first-yargs-project/node_modules/ts-node/src/index.ts:1059:12)
    at Module.load (internal/modules/cjs/loader.js:863:32)
    at Function.Module._load (internal/modules/cjs/loader.js:708:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12)
    at main (/home/mypc/projects/my-first-yargs-project/node_modules/ts-node/src/bin.ts:198:14)
    at Object.<anonymous> (/home/mypc/projects/my-first-yargs-project/node_modules/ts-node/src/bin.ts:288:3)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions