vuejs / vitepress

Vite & Vue powered static site generator.
https://vitepress.dev
MIT License
11.33k stars 1.83k forks source link

build: ReferenceError: document is not defined #3789

Closed DvShu closed 2 weeks ago

DvShu commented 2 weeks ago

Describe the bug

When I run npm run docs:build, I get the error: ReferenceError: document is not defined

Reproduction

If there is anything about node manipulation in my code, it will report an error. egg: document、DOMParser

Expected behavior

When I run npm run docs:dev its fine! But when i run npm run npm run docs:build i got the error.

System Info

System:
    OS: Windows 11 10.0.22631
    CPU: (16) x64 Intel(R) Core(TM) i7-10870H CPU @ 2.20GHz
    Memory: 4.36 GB / 15.83 GB
  Binaries:
    Node: 21.7.1 - D:\developer tool\nodejs\node.EXE
    Yarn: 1.22.19 - D:\developer tool\nodejs\yarn.CMD
    npm: 10.5.0 - D:\developer tool\nodejs\npm.CMD
    pnpm: 8.15.6 - D:\developer tool\nodejs\pnpm.CMD
  Browsers:
    Edge: Chromium (123.0.2420.81)
    Internet Explorer: 11.0.22621.1

Additional context

1713093865913 1713093899031

Validations

brc-dd commented 2 weeks ago

https://vitepress.dev/guide/ssr-compat