Skip to main content

Install docusaurus on Windows

· 3 min read

Docusaurus on Windows

Install docusaurus on Windows

Docusaurus is an open source project for building, deploying and maintaining websites. You create a local copy of new web pages with Markdown and docusaurus will build a static website for deployment.

This article will detail the steps necessary to get it up and running on Windows 11.

tip

We will use Windows Powershell, the fnm version manager to install latest node.js environment and finally Docusaurus

Installing Node.js with fnm

As docusaurus uses a node.js server environment, we will start installing this server environment on Windows 11.

  • Open a Powershell as Administrator
  • There are several package managers available to choose from, let's use fnm. For further options, look here
Install node.js with fnm
# installs fnm (Fast Node Manager)
winget install Schniz.fnm

# Set the fnm environment
fnm env --use-on-cd | Out-String | Invoke-Expression

# download and install Node.js
fnm use --install-if-missing 22

# verifies the right Node.js version is in the environment
node -v # should print `v22.2.0`

# verifies the right NPM version is in the environment
npm -v # should print `10.7.0`

Installing Docusaurus with npx

  • With this done, we can simply create a test docusaurus site:
Create test docusaurus site with npx
npx create-docusaurus@latest my-website classic
  • When asked for 'Javascript' or 'Typescript', use 'Typescript'
  • You should shortly see some summary like this:
Create test docusaurus site with npx
Need to install the following packages:
create-docusaurus@3.3.2
Ok to proceed? (y)

√ Which language do you want to use? » TypeScript
[INFO] Creating new Docusaurus project...
[INFO] Installing dependencies with npm...
[SUCCESS] Created my-website.
[INFO] Inside that directory, you can run several commands:

`npm start`
Starts the development server.

`npm run build`
Bundles your website into static files for production.

`npm run clear`
Cleans the build and cache folders.

`npm run serve`
Serves the built website locally.

`npm run deploy`
Publishes the website to GitHub pages.

We recommend that you begin by typing:

`cd my-website`
`npm start`
  • that's it - enter your website directory and start it locally with 'npm start'
  • You might get the warning "(node:34304) [DEP0040] DeprecationWarning: The punycode module is deprecated." - you can ignore it, will be fixed in future versions of node.js

Deploying a Docusaurus web site

If you deploy the built website to any server, have a look here as you need a Node.js environment for this

Re-Initialize an existing Docusaurus site

If you want to use an already existing docusaurus project with this new installation, you wold have to do some more steps:

Reinitialize existing website
npx docusaurus-init
npm install

Now, npm start should work. If you get an "npm not found" error message, it might be that your environment needs to be establisehd prioir to launching. You can do that easily with a small PowerShell script like:

Powershell to init npm env and build site
# Change to drive and directory of your docusaurus site
cd "MySiteFolder"

# Set environment
fnm env --use-on-cd | Out-String | Invoke-Expression

# Build site
npm run build

# Add a pause at the end of the script
Write-Host "Press Enter to exit script" -ForegroundColor White
Read-Host