Skip to content

[Error] failed to import yargs-parser in args.js #885

@leosuncin

Description

@leosuncin

The v8.0.0 throws an error when using the test helper

import type { FastifyInstance } from 'fastify';
import helper from 'fastify-cli/helper.js';

export function config() {
  return {
    skipOverride: true,
  };
}

export async function build(): Promise<FastifyInstance & AsyncDisposable> {
  const argv = [AppPath];
  const options = config();
  const app: FastifyInstance = await helper.build(argv, options);

  await app.ready();

  return Object.assign(app, {
    [Symbol.asyncDispose]: async () => {
      await app.close();
    },
  });
}
TypeError: argv is not a function
TypeError: argv is not a function
      at parseArgs (/home/runner/work/conduit-monorepo/conduit-monorepo/node_modules/.pnpm/fastify-cli@8.0.0/node_modules/fastify-cli/args.js:26:32)
      at runFastify (/home/runner/work/conduit-monorepo/conduit-monorepo/node_modules/.pnpm/fastify-cli@8.0.0/node_modules/fastify-cli/start.js:102:16)
      at Object.build (/home/runner/work/conduit-monorepo/conduit-monorepo/node_modules/.pnpm/fastify-cli@8.0.0/node_modules/fastify-cli/helper.js:13:12)
      at build (/home/runner/work/conduit-monorepo/conduit-monorepo/apps/backend/tests/helper.ts:55:45)
      at process.processTicksAndRejections (node:internal/process/task_queues:104:5)
      at async TestContext. (/home/runner/work/conduit-monorepo/conduit-monorepo/apps/backend/tests/plugins/health-check.test.ts:9:21)
      at async Test.run (node:internal/test_runner/test:1125:7)
      at async startSubtestAfterBootstrap (node:internal/test_runner/harness:358:3)

Line which throws the error

const commandLineArguments = argv(args, {

Debugging and setting a breakpoint shows that the function is an object rather than a function

Image

My guest is the import causes the error

const argv = require('yargs-parser')

OS info

OS: Linux
Node version: 24.14.0
pnpm: 10.33.4

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