Skip to content

yargs.command is not a function #1774

@manuscriptmastr

Description

@manuscriptmastr

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions