Skip to content

TypeError: Invalid URL while trying to build with sitemap not set to false #8116

@chreniuc

Description

@chreniuc

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

I'm using v2.1.0 and I've noticed that I get an error when I want to create a production build with sitemap not set to false, the yarn run start works with no issue, but when I run yarn run build I get a build error. If I set the sitemap option to false, it builds without errors. I use it as a blog only.

Reproducible demo

No response

Steps to reproduce

git clone https://gitlab.com/chreniuc/hreniuc-dev -b failed_build
cd hreniuc-dev
yarn install
yarn run build

Expected behavior

To build successfully.

Actual behavior

I'm receiving this error:

[ERROR] Unable to build website for locale en.
[ERROR] TypeError: Invalid URL
    at new NodeError (node:internal/errors:372:5)
    at URL.onParseError (node:internal/url:553:9)
    at new URL (node:internal/url:629:5)
    at new URL (node:internal/url:626:22)
    at normalizeURL (/path/node_modules/sitemap/dist/lib/utils.js:274:15)
    at SitemapStream._transform (/path/node_modules/sitemap/dist/lib/sitemap-stream.js:74:87)
    at SitemapStream.Transform._write (node:internal/streams/transform:184:23)
    at writeOrBuffer (node:internal/streams/writable:389:12)
    at _write (node:internal/streams/writable:330:10)
    at SitemapStream.Writable.write (node:internal/streams/writable:334:10)
    at /path/node_modules/@docusaurus/plugin-sitemap/lib/createSitemap.js:44:57
    at Array.forEach (<anonymous>)
    at createSitemap (/path/node_modules/@docusaurus/plugin-sitemap/lib/createSitemap.js:44:20)
    at Object.postBuild (/path/node_modules/@docusaurus/plugin-sitemap/lib/index.js:23:72)
    at /path/node_modules/@docusaurus/core/lib/commands/build.js:171:22
    at Array.map (<anonymous>)
    at buildLocale (/path/node_modules/@docusaurus/core/lib/commands/build.js:167:31)
    at async tryToBuildLocale (/path/node_modules/@docusaurus/core/lib/commands/build.js:38:20)
    at async mapAsyncSequential (/path/node_modules/@docusaurus/utils/lib/jsUtils.js:34:24)
    at async Command.build (/path/node_modules/@docusaurus/core/lib/commands/build.js:73:21)
[INFO] Docusaurus version: 2.1.0
Node version: v16.15.0
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Your environment

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.hacktoberfest

    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