Upgrading Docusaurus from 3.1.0 to 3.9.2 | Node.js 20 Migration Guide
A practical guide to upgrading Docusaurus from v3.1.0 to v3.9.2, migrating to Node.js 20, fixing MDX and Markdown issues, and resolving common build errors.

Maintaining documentation is a long-term commitment. As frameworks evolve, upgrades become inevitable to stay secure, supported, and compatible with modern tooling. This blog documents a real-world upgrade journey from Docusaurus 3.1.0 to Docusaurus 3.9.2, along with a Node.js upgrade to version 20, and the MDX and Markdown fixes required to get the project building successfully again.
The goal of this guide is to help teams avoid common pitfalls and understand why certain issues appear during the upgrade.
Why Upgrade Docusaurus and Node.js
Docusaurus Upgrade Motivation
Upgrading from Docusaurus 3.1.0 to 3.9.2 provides:
- Improved MDX parsing and validation
- Better ESM and Vite compatibility
- Security fixes and dependency updates
- More predictable theme and plugin behavior
Node.js 20 Requirement
Docusaurus 3.9.2 officially supports modern Node.js versions. Node.js 16 is deprecated, and Node.js 18 is approaching maintenance mode. Upgrading to Node.js 20 ensures:
- Long-term support
- Faster builds
- Better compatibility with modern tooling
For teams deploying documentation alongside applications on Nife’s platform, aligning Node.js versions avoids runtime inconsistencies.
Step 1: Upgrade Node.js to Version 20
Before touching Docusaurus, ensure Node.js is upgraded.
Using NVM:
nvm install 20
nvm use 20
node -v
Verify npm as well:
npm -v
Clean the environment:
rm -rf node_modules package-lock.json
npm cache clean --force
Step 2: Upgrade Docusaurus to 3.9.2
Update all Docusaurus-related dependencies together to avoid version mismatches.
npm install @docusaurus/core@3.9.2 \
@docusaurus/preset-classic@3.9.2
If you are using additional plugins or themes, upgrade them to matching versions.
After installation:
npm install
npm run build
At this stage, most projects will fail due to MDX or theme-related issues.
Step 3: Common MDX and Markdown Breaking Changes
1. Stricter MDX Parsing
Docusaurus 3.9.2 enforces stricter MDX rules.
Common Issues
- Unclosed JSX tags
- Invalid HTML inside Markdown
- Incorrect frontmatter formatting
- Trailing commas in arrays
Example Fix
Incorrect:
<img src="./img/sample.png">
Correct:
<img src="./img/sample.png" />
2. Frontmatter Validation Errors
Ensure all frontmatter fields are valid YAML.
Incorrect:
keywords: [docs, guide, ]
Correct:
keywords: [docs, guide]
3. JSX Must Be Explicit in MDX
Any JSX expression must be properly wrapped.
Incorrect:
{someFunction()}
Correct:
{someFunction && someFunction()}
Step 4: Fixing Image Imports in MDX
Docusaurus 3.x requires explicit image imports when using JSX.
Recommended pattern:
<img
src={require('./img/architecture.png').default}
alt="Architecture Diagram"
width="800"
/>
Avoid relative Markdown image syntax for complex layouts.
Step 5: Theme Component Errors After Upgrade
One of the most common errors during upgrade:
Module not found: Error: Can't resolve '@theme/Hero'
Why This Happens
- Docusaurus 3.9.2 removed or refactored internal theme components
- Custom themes built for older versions are incompatible
Resolution Strategy
- Temporarily disable all custom theme components
- Replace theme imports with standard MDX or React components
- Gradually reintroduce custom components after validation
Example removal:
// Remove this
import Hero from '@theme/Hero';
Step 6: Sidebar and Routing Validation
Docusaurus 3.9.2 enforces stricter route validation.
Ensure:
- All sidebar paths exist
- Slugs are unique
- No duplicate document IDs
Run:
npm run clear
npm run build
Step 7: Final Build and Verification
Once MDX and theme issues are resolved:
npm run build
npm run serve
Verify:
- All pages load correctly
- Sidebar navigation works
- Images render as expected
- No console warnings or errors
Key Takeaways
- Always upgrade Node.js before upgrading Docusaurus
- Expect MDX parsing to be stricter in newer versions
- Custom themes are the most common breaking point
- Clean installs prevent dependency conflicts
- Incremental fixes are faster than mass refactors
Conclusion
Upgrading from Docusaurus 3.1.0 to 3.9.2 with Node.js 20 is not just a dependency bump. It is a validation of documentation quality, MDX correctness, and long-term maintainability**Nife containerized deployments**.
By addressing MDX issues early and removing outdated theme dependencies, teams can ensure a smooth and future-proof documentation platform.
This upgrade prepares your documentation for scalability, security, and continued evolution alongside your product**Nife**.
From the team at Nife
Deploy your next app in minutes, not days.
Nife is a multi-cloud edge platform that lets you deploy, scale, and manage applications globally without the infrastructure headache.