Skip to content

Docusaurus CLI throws when no subcommand is provided and when not using conventional config name #9639

@xobotyi

Description

@xobotyi

Have you read the Contributing Guidelines on issues?

Prerequisites

  • I'm using the latest version of Docusaurus.
  • I have tried the npm run clear or yarn clear command.
  • I have tried rm -rf node_modules yarn.lock package-lock.json and re-installing packages.
  • I have tried creating a repro with https://new.docusaurus.io.
  • I have read the console error message carefully (if applicable).

Description

Attemt to specify custom location for docusaurus config fails with same error as if flag not provided at all, in fact, docusaurus seems not to take any flags at all, as --help flag (dont know if it exists at all) dont take any effect as well.

Reproducible demo

No response

Steps to reproduce

  1. define relative config path as --config <path>
  2. get an error that config not found

Expected behavior

--config flag takes effect

Actual behavior

Config file not read from specified path, though it exists

> ls ./.docusaurus/docusaurus.config.ts

Directory: ....\.docusaurus

Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
-a---          17.12.2023    23:27            811 docusaurus.config.ts

> yarn docusaurus --config ./.docusaurus/docusaurus.config.ts
yarn run v1.22.21
$ ....\node_modules\.bin\docusaurus --config ./.docusaurus/docusaurus.config.ts
[ERROR] No config file found.
[INFO] Expected one of:
- docusaurus.config.ts
- docusaurus.config.mts
- docusaurus.config.cts
- docusaurus.config.js
- docusaurus.config.mjs
- docusaurus.config.cjs
You can provide a custom config path with the `--config` option.
....\node_modules\@docusaurus\core\lib\server\config.js:24
throw new Error();
^

Error
at findConfig (....\node_modules\@docusaurus\core\lib\server\config.js:24:15)
at async loadSiteConfig (....\node_modules\@docusaurus\core\lib\server\config.js:31:11)
at async loadContext (....\node_modules\@docusaurus\core\lib\server\index.js:31:63)
at async externalCommand (....\node_modules\@docusaurus\core\lib\commands\external.js:16:21)
at async file:///..../node_modules/@docusaurus/core/bin/docusaurus.mjs:241:3

Node.js v20.10.0
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Your environment

  • Docusaurus version used: 3.0.1
  • Environment name and version (e.g. Chrome 89, Node.js 16.4): Nodejs v20.10.0
  • Operating system and version (e.g. Ubuntu 20.04.2 LTS): Windows 11

Self-service

  • I'd be willing to fix this bug myself.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugAn error in the Docusaurus core causing instability or issues with its executiongood first issueIf you are just getting started with Docusaurus, this issue should be a good place to begin.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions