question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[v2] `build` does not work on a fresh install

See original GitHub issue

🐛 Bug Report

After creating a fresh docusaurus page and executing yarn run build, it build Client successfully, but throws an error when building Server starting with Error: Cannot find module '@theme/NotFound' (see below for the full log).

Have you read the Contributing Guidelines on issues?

Yes.

To Reproduce

  1. Create new Docusaurus v2 page: npx @docusaurus/init@next init test classic
  2. Enter the directory: cd test
  3. Run build: yarn run build

Expected behavior

Static page is built.

Actual Behavior

The following error message is displayed:

yarn run v1.22.4
$ docusaurus build
Creating an optimized production build...

✔ Client
  Compiled successfully in 8.91s

✖ Server
  Compiled with some errors in 9.94s



Error: Cannot find module '@theme/NotFound'
    at async Promise.all (index 0)Error: Cannot find module '@site/src/pages/index.js'Error: Cannot find module '@theme/BlogListPage'Error: Cannot find module '@theme/BlogPostPage'Error: Cannot find module '@theme/BlogPostPage'Error: Cannot find module '@theme/BlogTagsListPage'Error: Cannot find module '@theme/BlogTagsPostsPage'Error: Cannot find module '@theme/BlogTagsPostsPage'Error: Cannot find module '@theme/BlogTagsPostsPage'Error: Cannot find module '@theme/BlogTagsPostsPage'Error: Cannot find module '@theme/BlogPostPage'Error: Cannot find module '@theme/DocPage'Error: Cannot find module '@theme/DocPage'Error: Cannot find module '@theme/DocPage'Error: Cannot find module '@theme/DocPage'
(undefined) Error: Cannot find module '@theme/NotFound'
    at webpackEmptyContext (main:30401:10)
    at main:31155:171
    at async Promise.all (index 0)
    at async render (main:31262:137)
(undefined) Error: Cannot find module '@site/src/pages/index.js'
    at webpackEmptyContext (main:152:10)
    at main:31140:3411
(undefined) Error: Cannot find module '@theme/BlogListPage'
    at webpackEmptyContext (main:152:10)
    at main:31140:2517
(undefined) Error: Cannot find module '@theme/BlogPostPage'
    at webpackEmptyContext (main:152:10)
    at main:31140:3579
(undefined) Error: Cannot find module '@theme/BlogPostPage'
    at webpackEmptyContext (main:152:10)
    at main:31140:3579
(undefined) Error: Cannot find module '@theme/BlogTagsListPage'
    at webpackEmptyContext (main:152:10)
    at main:31140:160
(undefined) Error: Cannot find module '@theme/BlogTagsPostsPage'
    at webpackEmptyContext (main:152:10)
    at main:31140:1758
(undefined) Error: Cannot find module '@theme/BlogTagsPostsPage'
    at webpackEmptyContext (main:152:10)
    at main:31140:1758
(undefined) Error: Cannot find module '@theme/BlogTagsPostsPage'
    at webpackEmptyContext (main:152:10)
    at main:31140:1758
(undefined) Error: Cannot find module '@theme/BlogTagsPostsPage'
    at webpackEmptyContext (main:152:10)
    at main:31140:1758
(undefined) Error: Cannot find module '@theme/BlogPostPage'
    at webpackEmptyContext (main:152:10)
    at main:31140:3579
(undefined) Error: Cannot find module '@theme/DocPage'
    at webpackEmptyContext (main:152:10)
    at main:31140:475
(undefined) Error: Cannot find module '@theme/DocPage'
    at webpackEmptyContext (main:152:10)
    at main:31140:475
(undefined) Error: Cannot find module '@theme/DocPage'
    at webpackEmptyContext (main:152:10)
    at main:31140:475
(undefined) Error: Cannot find module '@theme/DocPage'
    at webpackEmptyContext (main:152:10)
    at main:31140:475
(undefined) ./node_modules/@docusaurus/core/lib/client/exports/ComponentCreator.js 7:126-136
Critical dependency: the request of a dependency is an expression
(undefined) ./.docusaurus/registry.js 1:231-241
Critical dependency: the request of a dependency is an expression
(undefined) ./.docusaurus/registry.js 1:400-410
Critical dependency: the request of a dependency is an expression
(undefined) ./.docusaurus/registry.js 1:551-561
Critical dependency: the request of a dependency is an expression
(undefined) ./.docusaurus/registry.js 1:713-723
Critical dependency: the request of a dependency is an expression
(undefined) ./.docusaurus/registry.js 1:904-914
Critical dependency: the request of a dependency is an expression
(undefined) ./.docusaurus/registry.js 1:1106-1116
Critical dependency: the request of a dependency is an expression
(undefined) ./.docusaurus/registry.js 1:1324-1334
Critical dependency: the request of a dependency is an expression
(undefined) ./.docusaurus/registry.js 1:1565-1575
Critical dependency: the request of a dependency is an expression
(undefined) ./.docusaurus/registry.js 1:1752-1762
Critical dependency: the request of a dependency is an expression
(undefined) ./.docusaurus/registry.js 1:1921-1931
Critical dependency: the request of a dependency is an expression
(undefined) ./.docusaurus/registry.js 1:2113-2123
Critical dependency: the request of a dependency is an expression
(undefined) ./.docusaurus/registry.js 1:2321-2331
Critical dependency: the request of a dependency is an expression
(undefined) ./.docusaurus/registry.js 1:2532-2542
Critical dependency: the request of a dependency is an expression
(undefined) ./.docusaurus/registry.js 1:2748-2758
Critical dependency: the request of a dependency is an expression
(undefined) ./.docusaurus/registry.js 1:2942-2952
Critical dependency: the request of a dependency is an expression
(undefined) ./.docusaurus/registry.js 1:3163-3173
Critical dependency: the request of a dependency is an expression
(undefined) ./.docusaurus/registry.js 1:3327-3337
Critical dependency: the request of a dependency is an expression
(undefined) ./.docusaurus/registry.js 1:3503-3513
Critical dependency: the request of a dependency is an expression
(undefined) ./.docusaurus/registry.js 1:3694-3704
Critical dependency: the request of a dependency is an expression
(undefined) ./.docusaurus/registry.js 1:3870-3880
Critical dependency: the request of a dependency is an expression
(undefined) ./.docusaurus/registry.js 1:4034-4044
Critical dependency: the request of a dependency is an expression
(undefined) ./.docusaurus/registry.js 1:4213-4223
Critical dependency: the request of a dependency is an expression
(undefined) ./.docusaurus/registry.js 1:4412-4422
Critical dependency: the request of a dependency is an expression
(undefined) ./.docusaurus/registry.js 1:4590-4600
Critical dependency: the request of a dependency is an expression
Error: Failed to compile with errors.
    at /home/m4tx/husarion/test/node_modules/@docusaurus/core/lib/commands/build.js:37:24
    at finalCallback (/home/m4tx/husarion/test/node_modules/webpack/lib/MultiCompiler.js:254:12)
    at /home/m4tx/husarion/test/node_modules/webpack/lib/MultiCompiler.js:277:6
    at done (/home/m4tx/husarion/test/node_modules/neo-async/async.js:2931:13)
    at runCompilers (/home/m4tx/husarion/test/node_modules/webpack/lib/MultiCompiler.js:181:48)
    at /home/m4tx/husarion/test/node_modules/webpack/lib/MultiCompiler.js:188:7
    at /home/m4tx/husarion/test/node_modules/webpack/lib/MultiCompiler.js:270:7
    at finalCallback (/home/m4tx/husarion/test/node_modules/webpack/lib/Compiler.js:257:39)
    at /home/m4tx/husarion/test/node_modules/webpack/lib/Compiler.js:273:13
    at AsyncSeriesHook.eval [as callAsync] (eval at create (/home/m4tx/husarion/test/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:40:1)
    at AsyncSeriesHook.lazyCompileHook (/home/m4tx/husarion/test/node_modules/tapable/lib/Hook.js:154:20)
    at onCompiled (/home/m4tx/husarion/test/node_modules/webpack/lib/Compiler.js:271:21)
    at /home/m4tx/husarion/test/node_modules/webpack/lib/Compiler.js:681:15
    at AsyncSeriesHook.eval [as callAsync] (eval at create (/home/m4tx/husarion/test/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:4:1)
    at AsyncSeriesHook.lazyCompileHook (/home/m4tx/husarion/test/node_modules/tapable/lib/Hook.js:154:20)
    at /home/m4tx/husarion/test/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.

Your Environment

  • Docusaurus version used: 2.0.0-alpha.50
  • Environment name and version (e.g. Chrome 78.0.3904.108, Node.js 10.17.0): Node v13.13.0, npm 6.14.4, yarn 1.22.4
  • Operating system and version (desktop or mobile): Arch Linux, rolling

Reproducible Demo

https://github.com/m4tx/docusaurus-test

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:4
  • Comments:15 (2 by maintainers)

github_iconTop GitHub Comments

5reactions
lex111commented, Apr 21, 2020

Please add the code below to your package.json file and reinstall your deps.

UPD: The building of website should work as before!

  "resolutions": {
    "babel-plugin-dynamic-import-node": "2.3.0"
  }

We will pin the version of this dependency (babel-plugin-dynamic-import-node) in the next release and you (and our new users) will not need to do any manual work, so think about this as a workaround then!

We will consider a solution to use the exact versions of the dependencies used (without caret (^) char) to avoid similar problems in the future!

Sorry about that!

3reactions
luxplanjaycommented, Apr 21, 2020

Possibly related to #2244. Not swizzling any components might be a workaround for the issue.

In my case no components were implemented or used, just pure md files.

Read more comments on GitHub >

github_iconTop Results From Across the Web

5.1. Quickstart — Cabal 3.0.2.0 User's Guide
Unlike sandboxes, there is no need to setup a sandbox or add-source projects; just check in cabal.project to your repository and v2-build will...
Read more >
Troubleshoot Visual Studio installation and upgrade issues
This troubleshooting guide includes step-by-step instructions that should resolve most installation issues.
Read more >
Android Studio error "Installed Build Tools revision 31.0.0 ...
2 and you do not need to downgrade the SDK build tool from 31 to 30 or change compile SDK version. The main...
Read more >
Guide: What to do AFTER building your computer... - YouTube
Everyone always shows you HOW to build a computer... but here is what you do AFTER its built! Learn more about Corsairs new...
Read more >
How to perform a fresh install of GameMaker
The reason GameMaker may have been giving you your issues was because either your Windows/Mac user account is not suitable for writing files...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found