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

Docusaurus fails to build in docker (Module not found: Can't resolve ...) #10683

Closed
5 of 7 tasks
Gijsdeman opened this issue Nov 15, 2024 · 8 comments
Closed
5 of 7 tasks
Labels
bug An error in the Docusaurus core causing instability or issues with its execution external This issue is caused by an external dependency and not Docusaurus.

Comments

@Gijsdeman
Copy link

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

With the latest version of Docusaurus, builds seem to fail inside Docker containers due to resolve issues. This is an issue with @docusaurus/faster when enabling rspackBundler in the experimental_faster. This introduces the dependency on @rspack/bindings@1.1.1, which currently fails to resolve node_modules in Docker containers.

Docusaurus uses @rspack/core@^1.0.14, however, this resolves @rspack/bindings@1.1.1 rather than @rspack/bindings@@1.0.14.

This issue is more meant for people currently experiencing this behavour. To fix it, at least for yarn, add the following to package.json:

"resolutions": {
    "@rspack/core": "1.0.14",
    "@rspack/binding": "1.0.14"
},

Reproducible demo

No response

Steps to reproduce

  1. npx create-docusaurus@latest my-website classic --typescript
  2. cd my-website
  3. yarn add @docusaurus/faster
  4. Add future: { experimental: true }, to the docusaurus.config.ts
  5. docker run --rm -it -v .:/my-website node:18.20-alpine sh
  6. cd my-website
  7. yarn build

Expected behavior

For the Docusaurus website to build without any issues.

Actual behavior

The following error is shown

[ERROR] Client bundle compiled with errors therefore further build is impossible.
× Module not found: Can't resolve '/my-website/node_modules/@docusaurus/core/lib/client/clientEntry.js' in '/my-website'

Your environment

  • Docusaurus version used: 3.6.1
  • Environment name and version (e.g. Chrome 89, Node.js 16.4): docker image node:18.20-alpine, but persists accross multiple images
  • Operating system and version (e.g. Ubuntu 20.04.2 LTS): Ubuntu 20.04 LTS

Self-service

  • I'd be willing to fix this bug myself.
@Gijsdeman Gijsdeman 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 Nov 15, 2024
@Gijsdeman
Copy link
Author

Also see web-infra-dev/rspack#8433.

@slorber
Copy link
Collaborator

slorber commented Nov 15, 2024

Have you tried fully regenerating your lock file?

It should work with Rspack 1.1.1
#10648

Is this only happening inside Docker, and not outside? How can we be sure this is even related to docker?

Can we have a repro including an exact lockfile?

@slorber slorber removed the status: needs triage This issue has not been triaged by maintainers label Nov 15, 2024
@Gijsdeman
Copy link
Author

Gijsdeman commented Nov 15, 2024

Lock file has been fully regenerated. Local builds indeed work correctly, for me this only happens in Docker containers. Issue seems not to be isolated to Docusaurus, as more reports are coming in from different projects that use rspack/bindings@1.1.1, see web-infra-dev/rspack#8433. This module seems to be responsible for node binding, and has some optional dependencies that seem to be related to your platform.

  optionalDependencies:
    "@rspack/binding-darwin-arm64" "1.0.14"
    "@rspack/binding-darwin-x64" "1.0.14"
    "@rspack/binding-linux-arm64-gnu" "1.0.14"
    "@rspack/binding-linux-arm64-musl" "1.0.14"
    "@rspack/binding-linux-x64-gnu" "1.0.14"
    "@rspack/binding-linux-x64-musl" "1.0.14"
    "@rspack/binding-win32-arm64-msvc" "1.0.14"
    "@rspack/binding-win32-ia32-msvc" "1.0.14"
    "@rspack/binding-win32-x64-msvc" "1.0.14"

This is not necessarily within my area of expertise, but different bindings based on different platforms could explain why the build succeeds locally, but fails in a Docker container. Could also imply that it will success/fail depending on your platform altogether.

As for the lockfile, please refer to this repository. Note that I only generated the yarn.lock files.

@slorber
Copy link
Collaborator

slorber commented Nov 15, 2024

I see, thanks for investigating, will track the Rspack related issue.

@Gijsdeman
Copy link
Author

Looking into this a bit further, alpine contains use musl, while Ubuntu containers use gnu. I run both on linux with x64 architecture, so that would narrow down the issue quite a lot.

As mentioned above, I made this issue mostly to inform others that run into this problem, I will report any further findings in the rspack repository.

@Josh-Cena Josh-Cena added the external This issue is caused by an external dependency and not Docusaurus. label Nov 16, 2024
@etal2
Copy link

etal2 commented Nov 18, 2024

Seeing the same issue when the creating a clean project and running directly on linux (not in docker).

npx create-docusaurus@latest web-docs2 classic --typescript
npm i @docusaurus/faster

project initially builds fine but after adding

future: {
    experimental_faster: true,
}

see the same Module not found: Can't resolve clientEntry.js message, setting rspackBundler: false fixes the issue.

@Gijsdeman
Copy link
Author

Should be resolved in the upcoming 1.1.2 version of rspack:

@slorber
Copy link
Collaborator

slorber commented Nov 20, 2024

Going to assume it's fixed if you upgrade Rspack to v1.1.2 (which our deps range allow you to do)

Let us know if it's not the case

@slorber slorber closed this as not planned Won't fix, can't repro, duplicate, stale Nov 20, 2024
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 external This issue is caused by an external dependency and not Docusaurus.
Projects
None yet
Development

No branches or pull requests

4 participants