Skip to content

"TypeError: Cannot read property 'replace' of undefined" when docusaurus buildΒ #3657

Description

@kumarabhirup

πŸ› Bug Report

I am using Docusaurus 2.

I get this error when I run docusaurus build,

Creating an optimized production build...

βœ” Client
  Compiled successfully in 1.21m

βœ– Server
  Compiled with some errors in 1.35m

TypeError: Cannot read property 'replace' of undefined
    at String.replace (<anonymous>)TypeError: Cannot read property 'replace' of undefined
    at String.replace (<anonymous>)TypeError: Cannot read property 'replace' of undefined
    at String.replace (<anonymous>)TypeError: Cannot read property 'replace' of undefined
    at String.replace (<anonymous>)TypeError: Cannot read property 'replace' of undefined
    at String.replace (<anonymous>)TypeError: Cannot read property 'replace' of undefined
    at String.replace (<anonymous>)TypeError: Cannot read property 'replace' of undefined
    at String.replace (<anonymous>)TypeError: Cannot read property 'replace' of undefined
    at String.replace (<anonymous>)TypeError: Cannot read property 'replace' of undefined
    at String.replace (<anonymous>)TypeError: Cannot read property 'replace' of undefined
    at String.replace (<anonymous>)
(undefined) TypeError: Cannot read property 'replace' of undefined
    at Object.options.minifyJS (main:18886:28)
    at Object.chars (main:19374:24)
    at main:48346:19
    at String.replace (<anonymous>)
    at new HTMLParser (main:48338:19)
    at minify (main:19160:3)
    at module.exports.exports.minify (main:19521:16)
    at serverEntry_render (main:88195:38)
(undefined) TypeError: Cannot read property 'replace' of undefined
    at Object.options.minifyJS (main:18886:28)
    at Object.chars (main:19374:24)
    at main:48346:19
    at String.replace (<anonymous>)
    at new HTMLParser (main:48338:19)
    at minify (main:19160:3)
    at module.exports.exports.minify (main:19521:16)
    at serverEntry_render (main:88195:38)
(undefined) TypeError: Cannot read property 'replace' of undefined
    at Object.options.minifyJS (main:18886:28)
    at Object.chars (main:19374:24)
    at main:48346:19
    at String.replace (<anonymous>)
    at new HTMLParser (main:48338:19)
    at minify (main:19160:3)
    at module.exports.exports.minify (main:19521:16)
    at serverEntry_render (main:88195:38)
(undefined) TypeError: Cannot read property 'replace' of undefined
    at Object.options.minifyJS (main:18886:28)
    at Object.chars (main:19374:24)
    at main:48346:19
    at String.replace (<anonymous>)
    at new HTMLParser (main:48338:19)
    at minify (main:19160:3)
    at module.exports.exports.minify (main:19521:16)
    at serverEntry_render (main:88195:38)
(undefined) TypeError: Cannot read property 'replace' of undefined
    at Object.options.minifyJS (main:18886:28)
    at Object.chars (main:19374:24)
    at main:48346:19
    at String.replace (<anonymous>)
    at new HTMLParser (main:48338:19)
    at minify (main:19160:3)
    at module.exports.exports.minify (main:19521:16)
    at serverEntry_render (main:88195:38)
(undefined) TypeError: Cannot read property 'replace' of undefined
    at Object.options.minifyJS (main:18886:28)
    at Object.chars (main:19374:24)
    at main:48346:19
    at String.replace (<anonymous>)
    at new HTMLParser (main:48338:19)
    at minify (main:19160:3)
    at module.exports.exports.minify (main:19521:16)
    at serverEntry_render (main:88195:38)
(undefined) TypeError: Cannot read property 'replace' of undefined
    at Object.options.minifyJS (main:18886:28)
    at Object.chars (main:19374:24)
    at main:48346:19
    at String.replace (<anonymous>)
    at new HTMLParser (main:48338:19)
    at minify (main:19160:3)
    at module.exports.exports.minify (main:19521:16)
    at serverEntry_render (main:88195:38)
(undefined) TypeError: Cannot read property 'replace' of undefined
    at Object.options.minifyJS (main:18886:28)
    at Object.chars (main:19374:24)
    at main:48346:19
    at String.replace (<anonymous>)
    at new HTMLParser (main:48338:19)
    at minify (main:19160:3)
    at module.exports.exports.minify (main:19521:16)
    at serverEntry_render (main:88195:38)
(undefined) TypeError: Cannot read property 'replace' of undefined
    at Object.options.minifyJS (main:18886:28)
    at Object.chars (main:19374:24)
    at main:48346:19
    at String.replace (<anonymous>)
    at new HTMLParser (main:48338:19)
    at minify (main:19160:3)
    at module.exports.exports.minify (main:19521:16)
    at serverEntry_render (main:88195:38)
(undefined) TypeError: Cannot read property 'replace' of undefined
    at Object.options.minifyJS (main:18886:28)
    at Object.chars (main:19374:24)
    at main:48346:19
    at String.replace (<anonymous>)
    at new HTMLParser (main:48338:19)
    at minify (main:19160:3)
    at module.exports.exports.minify (main:19521:16)
    at serverEntry_render (main:88195:38)
Error: Failed to compile with errors.
    at /Users/kumarabhirup/Documents/Repositories/propagateAt/node_modules/@docusaurus/core/lib/webpack/utils.js:164:24
    at finalCallback (/Users/kumarabhirup/Documents/Repositories/propagateAt/node_modules/webpack/lib/MultiCompiler.js:254:12)
    at /Users/kumarabhirup/Documents/Repositories/propagateAt/node_modules/webpack/lib/MultiCompiler.js:277:6
    at done (/Users/kumarabhirup/Documents/Repositories/propagateAt/node_modules/neo-async/async.js:2931:13)
    at runCompilers (/Users/kumarabhirup/Documents/Repositories/propagateAt/node_modules/webpack/lib/MultiCompiler.js:181:48)
    at /Users/kumarabhirup/Documents/Repositories/propagateAt/node_modules/webpack/lib/MultiCompiler.js:188:7
    at /Users/kumarabhirup/Documents/Repositories/propagateAt/node_modules/webpack/lib/MultiCompiler.js:270:7
    at finalCallback (/Users/kumarabhirup/Documents/Repositories/propagateAt/node_modules/webpack/lib/Compiler.js:257:39)
    at /Users/kumarabhirup/Documents/Repositories/propagateAt/node_modules/webpack/lib/Compiler.js:273:13
    at AsyncSeriesHook.eval [as callAsync] (eval at create (/Users/kumarabhirup/Documents/Repositories/propagateAt/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:42:1)
    at AsyncSeriesHook.lazyCompileHook (/Users/kumarabhirup/Documents/Repositories/propagateAt/node_modules/tapable/lib/Hook.js:154:20)
    at onCompiled (/Users/kumarabhirup/Documents/Repositories/propagateAt/node_modules/webpack/lib/Compiler.js:271:21)
    at /Users/kumarabhirup/Documents/Repositories/propagateAt/node_modules/webpack/lib/Compiler.js:681:15
    at AsyncSeriesHook.eval [as callAsync] (eval at create (/Users/kumarabhirup/Documents/Repositories/propagateAt/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:6:1)
    at AsyncSeriesHook.lazyCompileHook (/Users/kumarabhirup/Documents/Repositories/propagateAt/node_modules/tapable/lib/Hook.js:154:20)
    at /Users/kumarabhirup/Documents/Repositories/propagateAt/node_modules/webpack/lib/Compiler.js:678:31
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Have you read the Contributing Guidelines on issues?

Yes

To Reproduce

  1. Use the following docusaurus.config.js
module.exports = {
  title: 'propagate.at',
  tagline: 'Email, WhatsApp and SMS Marketing for Online Creators',
  url: 'https://kb.propagate.at',
  baseUrl: '/',
  onBrokenLinks: 'throw',
  favicon: 'img/favicon.ico',
  organizationName: 'propagate-at', // Usually your GitHub org/user name.
  projectName: 'propagateAt', // Usually your repo name.
  themeConfig: {
    colorMode: {
      disableSwitch: true,
    },
    navbar: {
      // title: 'propagate.at',
      logo: {
        alt: 'PropagateAt Logo',
        src: 'img/PropagateAt Logo Light.svg'
      },
      items: [
        {
          to: 'docs/',
          activeBasePath: 'docs',
          label: 'Docs',
          position: 'left',
        },
        {to: 'blog', label: 'Press', position: 'left'},
        {
          href: 'https://github.com/propagate-at',
          label: 'GitHub',
          position: 'right',
        },
        {
          href: 'https://propagate.at/dashboard',
          label: 'Dashboard',
          position: 'right',
        },
      ],
    },
    footer: {
      style: 'light',
      logo: {
        alt: 'PropagateAt Logo',
        src: 'img/PropagateAt Logo Light.svg',
      },
      links: [
        {
          title: 'Docs',
          items: [
            {
              label: 'Developer API',
              to: 'docs/api/',
            },
            {
              label: 'Guides',
              to: 'docs/guides/',
            },
          ],
        },
        {
          title: 'Community',
          items: [
            {
              label: 'Discord',
              href: 'https://discord.gg/RHZMhgF',
            },
            {
              label: 'Twitter',
              href: 'https://twitter.com/propagateHQ',
            },
          ],
        },
        {
          title: 'Social',
          items: [
            // {
            //   label: 'Twitter',
            //   href: 'https://twitter.com/propagateHQ',
            // },
            {
              label: 'Facebook',
              href: 'https://fb.com/propagate.at',
            },
            {
              label: 'Instagram',
              href: 'https://www.instagram.com/propagate.at/',
            }
          ],
        },
        {
          title: 'More',
          items: [
            {
              label: 'Press',
              to: 'blog',
            },
            {
              label: 'GitHub',
              href: 'https://github.com/propagate-at',
            },
            {
              label: 'LinkedIn',
              href: 'https://www.linkedin.com/company/propagateAt',
            }
          ],
        },
      ],
      copyright: `Copyright © ${new Date().getFullYear()} PropagateAt, Inc. Built with ❀️ for creators.`,
    },
  },
  presets: [
    [
      '@docusaurus/preset-classic',
      {
        docs: {
          sidebarPath: require.resolve('./sidebars.js'),
          // Please change this to your repo.
          // editUrl:
          //   'https://github.com/facebook/docusaurus/edit/master/website/',
        },
        blog: {
          showReadingTime: true,
          // Please change this to your repo.
          // editUrl:
          //   'https://github.com/facebook/docusaurus/edit/master/website/blog/',
        },
        theme: {
          customCss: require.resolve('./src/css/custom.css'),
        },
      },
    ],
  ],
};
  1. Run docusaurus build.

Behavior

docusaurus start works perfectly fine for development purposes. After I got the expected result on dev stage, I ran docusaurus build. Then I got that error.

Btw, I am new to Docusaurus.

Your Environment

  • Docusaurus version used:
"@docusaurus/core": "2.0.0-alpha.66",
"@docusaurus/preset-classic": "2.0.0-alpha.66"
  • Environment name and version (e.g. Chrome 78.0.3904.108, Node.js 10.17.0): Chrome 86 | Node.js v15.0.1
  • Operating system and version (desktop or mobile): MacOS Mojave

Reproducible Demo

I will soon create a Demo Repo exclusively for this issue. Would like to get some time.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugAn error in the Docusaurus core causing instability or issues with its executionclosed: duplicateThis issue or pull request already exists in another issue or pull request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions