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).
Yes.
npx @docusaurus/init@next init test classiccd testbuild: yarn run buildStatic page is built.
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.
It seems that this bug is still relevant for v2.0.0-alpha.49 :confused:
I am getting this for all the versions I tried even with v2.0.0-alpha.50
Logs can be found at https://travis-ci.com/github/mayadata-io/oep-e2e/builds/161215563
Any workaround for this. Appreciated.
Exactly the same issue for me, was unable to finish production build after upgrading to alpha-50. It has something to do with theme past alpha-43. Fixed it by downgrading to pre-update yarn.lock where alpha-43 theme links were saved.
Possibly related to #2244. Not swizzling any components might be a workaround for the issue.
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.
Seeing the same on version 2.0.0-alpha.43 with preset-classic theme
Seeing the same on version
2.0.0-alpha.43with preset-classic theme
Did you upgrade to alpha.50 and then downgraded back to alpha.43. If that is the case check your yarn.lock, it actually still has alpha.50 theme links as deps. That's what happened to me.
@luxplanjay I have not, but will try that. Thanks.
Did you upgrade to
alpha.50and then downgraded back toalpha.43. If that is the case check your yarn.lock, it actually still hasalpha.50theme links as deps. That's what happened to me.
So before today I was on alpha.43 and had not upgraded yet to alpha.50 and I was getting these errors.
It looks like when installing any version of docusaurus the yarn.lock resolves to alpha.50 for several of the plugin packages. This was with a fresh install. Also, package.json is locked to alpha.40
package.json
{
"@docusaurus/core": "2.0.0-alpha.40",
"@docusaurus/preset-classic": "2.0.0-alpha.40",
}
yarn.lock
"@docusaurus/theme-classic@^2.0.0-alpha.40":
version "2.0.0-alpha.50"
resolved "https://registry.yarnpkg.com/@docusaurus/theme-classic/-/theme-classic-2.0.0-alpha.50.tgz#244062bde993a62dc31fe0d4593a7c3354b13b0b"
@coreybrown89 I've encountered a similar issue in the past, especially when using npm for package management. By default, npm doesn't honor the lock file for package installs, so we ended up adding npm ci right before our build command so it will always base package installs on the lock file. Anyway, yarn honors the lock file for installs by default.
Concerning the issue you pointed out, I suspect it has something to do with how dependencies are pinned in D2 - using the ^ symbol. To work around this, I ended up exhaustively pinning all package dependencies without the ^ symbol, which has worked much better so far (for npm).
Example:
"@docusaurus/core": "2.0.0-alpha.48",
"@docusaurus/mdx-loader": "2.0.0-alpha.48",
"@docusaurus/plugin-content-blog": "2.0.0-alpha.48",
"@docusaurus/plugin-content-docs": "2.0.0-alpha.48",
"@docusaurus/plugin-content-pages": "2.0.0-alpha.48",
"@docusaurus/plugin-google-analytics": "2.0.0-alpha.48",
"@docusaurus/plugin-google-gtag": "2.0.0-alpha.48",
"@docusaurus/plugin-sitemap": "2.0.0-alpha.40",
"@docusaurus/preset-classic": "2.0.0-alpha.48",
"@docusaurus/theme-classic": "2.0.0-alpha.48",
"@docusaurus/theme-live-codeblock": "2.0.0-alpha.48",
"@docusaurus/theme-search-algolia": "2.0.0-alpha.48",
"@docusaurus/types": "2.0.0-alpha.48",
"@docusaurus/utils": "2.0.0-alpha.48",
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!
Manual fix is no longer required, the building website should work as earlier.
https://github.com/airbnb/babel-plugin-dynamic-import-node/commit/5fdba6e43d1cf8ec768e2cba251691c3ea67e78e
Thanks a lot. Things have started to work without any changes!!
Thank you for the quick update! Much appreciated
Most helpful comment
Please add the code below to yourpackage.jsonfile and reinstall your deps.UPD: The building of website should work as before!
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!