Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

yargs.command is not a function #1774

Closed
manuscriptmastr opened this issue Oct 3, 2020 · 2 comments
Closed

yargs.command is not a function #1774

manuscriptmastr opened this issue Oct 3, 2020 · 2 comments

Comments

@manuscriptmastr
Copy link

I've been using yargs 15.4.1 for a CLI on Nodejs 14.8+ with ES Modules for some months. The index.js file is fairly simple:

import yargs from 'yargs';
import journal from './src/cli/journal';
import stats from './src/cli/stats';

yargs
  .command(journal)
  .command(stats)
  .demandCommand()
  .help()
  .argv
;

After upgrading to 16.0.3, I get a TypeError:

file://~/Documents/Development/pourover-cli/index.js:12
  .command(journal)
   ^

TypeError: yargs.command is not a function
    at file://~/Documents/Development/pourover-cli/index.js:12:4
    at ModuleJob.run (internal/modules/esm/module_job.js:146:23)
    at async Loader.import (internal/modules/esm/loader.js:165:24)
    at async Object.loadESM (internal/process/esm_loader.js:68:5)

Any thoughts? I suspect I'm missing an API change in v16?

@manuscriptmastr
Copy link
Author

UPDATE:

When I follow the ESM example exactly and invoke yargs first, it works:

yargs(hideBin(process.argv))
  .command(...)
  .command(...)
...

Not sure what this is doing, but it works!

@bcoe
Copy link
Member

bcoe commented Oct 8, 2020

👍 awesome, glad you sorted this out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants