Skip to content

yargs.terminalWidth() does not work: TypeError: import_yargs.default.terminalWidth is not a function #228

@pd60193

Description

@pd60193

Current code in bin.ts that throws an error:

yargs(hideBin(process.argv))
  .env('POSTHOG_WIZARD')
   // more chained methods
   .help()
  .alias('help', 'h')
  .version()
  .alias('version', 'v')
  .wrap(process.stdout.isTTY ? yargs.terminalWidth() : 80).argv;

Expected something like:

import yargs from 'yargs';
import { hideBin } from 'yargs/helpers';

// Create a yargs instance
const yargInstance = yargs(hideBin(process.argv));

// Use terminalWidth() on the instance
const terminalWidth = yargInstance.terminalWidth();

// Example of using the width with .wrap()
yargInstance.wrap(terminalWidth)
    .argv

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