Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
kumarabhirup opened this issue Oct 29, 2020 · 1 comment
Labels
bug An error in the Docusaurus core causing instability or issues with its execution closed: duplicate This issue or pull request already exists in another issue or pull request

Comments

@kumarabhirup
Copy link

πŸ› 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.

@kumarabhirup kumarabhirup added bug An error in the Docusaurus core causing instability or issues with its execution status: needs triage This issue has not been triaged by maintainers labels Oct 29, 2020
@slorber
Copy link
Collaborator

slorber commented Oct 29, 2020

hi

this is a known issue affecting yarn workspace / monorepos

you'll find workarounds here: #3515

@slorber slorber closed this as completed Oct 29, 2020
mahesh-krishnakumar added a commit to pupilfirst/pupilfirst that referenced this issue Dec 23, 2021
This fixes the failing build for developer documentation
Details: facebook/docusaurus#3657
@Josh-Cena Josh-Cena added closed: duplicate This issue or pull request already exists in another issue or pull request and removed status: needs triage This issue has not been triaged by maintainers labels Mar 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An error in the Docusaurus core causing instability or issues with its execution closed: duplicate This issue or pull request already exists in another issue or pull request
Projects
None yet
Development

No branches or pull requests

3 participants