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

Webpack dev server fails to start without static assets #10212

Closed
6 of 7 tasks
wtykirby opened this issue Jun 11, 2024 · 2 comments · Fixed by #10225
Closed
6 of 7 tasks

Webpack dev server fails to start without static assets #10212

wtykirby opened this issue Jun 11, 2024 · 2 comments · Fixed by #10225
Labels
bug An error in the Docusaurus core causing instability or issues with its execution

Comments

@wtykirby
Copy link

wtykirby commented Jun 11, 2024

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

I have a project that doesn't contain a static assets directory. This prevents the Webpack dev server from running due to a misconfiguration of the plugins added by Docusaurus. I was able to workaround this issue by adding a static directory and adding some content to it.

[SUCCESS] Docusaurus website is running at: http://localhost:3000/

[ERROR] TypeError: Cannot read properties of undefined (reading 'constructor')
     at /Users/william.kirby/Code/my-project/node_modules/webpack-dev-server/lib/Server.js:1860:22
     at Array.find (<anonymous>)
     at /Users/william.kirby/Code/my-project/node_modules/webpack-dev-server/lib/Server.js:1859:60
     at Array.forEach (<anonymous>)
     at Server.initialize (/Users/william.kirby/Code/my-project/node_modules/webpack-dev-server/lib/Server.js:1846:17)
     at Server.start (/Users/william.kirby/Code/my-project/node_modules/webpack-dev-server/lib/Server.js:3358:16)
     at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
     at async Command.start (/Users/william.kirby/Code/my-project/node_modules/@docusaurus/core/lib/commands/start/start.js:42:5)
[INFO] Docusaurus version: 3.4.0
Node version: v18.18.0

This appears to be a regression introduced in v3.4.0 by this PR: #9859
The createStaticDirectoriesCopyPlugin function returns undefined when no static directories exist and Webpack isn't able to handle this.

Reproducible demo

No response

Steps to reproduce

  1. Go to https://new.docusaurus.io/
  2. Create a new Docusaurus project with StackBlitz
  3. Kill the development server
  4. Delete the static directory
  5. Attempt to restart the development server

Expected behavior

I would expect the development server to run even if no static assets exist.

Actual behavior

The development server failed to start.

Your environment

  • Docusaurus version used: 3.4
  • Environment name and version (e.g. Chrome 89, Node.js 16.4): Node 18.18.0
  • Operating system and version (e.g. Ubuntu 20.04.2 LTS): MacOS 14.4.1

Self-service

  • I'd be willing to fix this bug myself.
@wtykirby wtykirby 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 Jun 11, 2024
@Cankar001
Copy link

Cankar001 commented Jun 14, 2024

Same issue here, and I am actually required to have this fixed asap, as I have a deadline, when my site has to be finished, so I would be willing to look into this issue as well :)

@Josh-Cena
Copy link
Collaborator

@Cankar001 There's absolutely nothing blocking you. The workaround is simple: just add a static folder.

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
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants